- | idAB?> |
+ idAB;?> |
priAB?> |
task->name;?> |
@@ -36,7 +36,7 @@
name?> |
estimate?> |
- deadline, 0, 4) > 0) echo $task->deadline;?> |
+ deadline, 0, 4) > 0) echo $task->deadline;?> |
diff --git a/module/common/lang/menuOrder.php b/module/common/lang/menuOrder.php
index 1c53de9cea..342ecd1dac 100644
--- a/module/common/lang/menuOrder.php
+++ b/module/common/lang/menuOrder.php
@@ -48,19 +48,15 @@ $lang->branch->menuOrder = $lang->product->menuOrder;
/* project menu order. */
$lang->project->menuOrder[5] = 'list';
-$lang->project->menuOrder[10] = 'index';
-$lang->project->menuOrder[15] = 'task';
+$lang->project->menuOrder[10] = 'kanban';
+$lang->project->menuOrder[15] = 'burn';
$lang->project->menuOrder[20] = 'story';
-$lang->project->menuOrder[25] = 'bug';
-$lang->project->menuOrder[30] = 'build';
-$lang->project->menuOrder[35] = 'testtask';
+$lang->project->menuOrder[25] = 'qa';
+$lang->project->menuOrder[30] = 'doc';
+$lang->project->menuOrder[35] = 'action';
$lang->project->menuOrder[40] = 'team';
-$lang->project->menuOrder[45] = 'dynamic';
-$lang->project->menuOrder[50] = 'doc';
-$lang->project->menuOrder[55] = 'product';
-$lang->project->menuOrder[60] = 'view';
-$lang->project->menuOrder[65] = 'create';
-$lang->project->menuOrder[70] = 'all';
+$lang->project->menuOrder[45] = 'product';
+$lang->project->menuOrder[50] = 'view';
$lang->task->menuOrder = $lang->project->menuOrder;
$lang->build->menuOrder = $lang->project->menuOrder;
diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php
index bc5832a81f..613a7b73ff 100644
--- a/module/common/lang/zh-cn.php
+++ b/module/common/lang/zh-cn.php
@@ -221,21 +221,42 @@ $lang->release->menu = $lang->product->menu;
$lang->project = new stdclass();
$lang->project->menu = new stdclass();
-$lang->project->menu->task = array('link' => '任务|project|task|projectID=%s', 'subModule' => 'task,tree', 'alias' => 'grouptask,importtask,burn,importbug,kanban,printkanban,tree');
+$lang->project->menu->list = array('link' => '%s', 'subModule' => 'task,tree', 'alias' => 'grouptask,importtask,importbug,tree');
+$lang->project->menu->kanban = array('link' => '看板|project|kanban|projectID=%s');
+$lang->project->menu->burn = array('link' => '燃尽图|project|burn|projectID=%s');
$lang->project->menu->story = array('link' => '需求|project|story|projectID=%s', 'subModule' => 'story', 'alias' => 'linkstory,storykanban');
-$lang->project->menu->bug = 'Bug|project|bug|projectID=%s';
-$lang->project->menu->dynamic = '动态|project|dynamic|projectID=%s';
-$lang->project->menu->build = array('link' => '版本|project|build|projectID=%s', 'subModule' => 'build');
-$lang->project->menu->testtask = array('link' => '测试单|project|testtask|projectID=%s');
-$lang->project->menu->team = array('link' => '团队|project|team|projectID=%s', 'alias' => 'managemembers');
+$lang->project->menu->qa = array('link' => '%s', 'subModule' => 'build');
$lang->project->menu->doc = array('link' => '文档|doc|objectLibs|type=project&objectID=%s&from=project', 'subModule' => 'doc');
+$lang->project->menu->action = array('link' => '%s');
$lang->project->menu->product = $lang->productCommon . '|project|manageproducts|projectID=%s';
+$lang->project->menu->team = array('link' => '团队|project|team|projectID=%s', 'alias' => 'managemembers');
$lang->project->menu->view = array('link' => '概况|project|view|projectID=%s', 'alias' => 'edit,start,suspend,putoff,close');
+$lang->project->subMenu = new stdclass();
+$lang->project->subMenu->list = new stdclass();
+$lang->project->subMenu->list->task = '任务列表|project|task|projectID=%s';
+$lang->project->subMenu->list->tree = '树状图|project|tree|projectID=%s';
+$lang->project->subMenu->list->groupTask = '分组视图|project|groupTask|projectID=%s';
+
+$lang->project->subMenu->qa = new stdclass();
+$lang->project->subMenu->qa->bug = 'Bug|project|bug|projectID=%s';
+$lang->project->subMenu->qa->build = '版本|project|build|projectID=%s';
+$lang->project->subMenu->qa->testtask = '测试单|project|testtask|projectID=%s';
+
+$lang->project->subMenu->action = new stdclass();
+$lang->project->subMenu->action->dynamic = '动态|project|dynamic|projectID=%s';
+
+$lang->project->dividerMenu = ',story,doc,';
+
$lang->task = new stdclass();
$lang->build = new stdclass();
-$lang->task->menu = $lang->project->menu;
-$lang->build->menu = $lang->project->menu;
+$lang->task->menu = $lang->project->menu;
+$lang->task->subMenu = $lang->project->subMenu;
+$lang->build->menu = $lang->project->menu;
+$lang->build->subMenu = $lang->project->subMenu;
+
+$lang->task->dividerMenu = $lang->project->dividerMenu;
+$lang->build->dividerMenu = $lang->project->dividerMenu;
/* QA视图菜单设置。*/
$lang->qa = new stdclass();
diff --git a/module/common/model.php b/module/common/model.php
index 60fe2fb5ee..23a92a32f7 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -456,40 +456,38 @@ class commonModel extends model
/* Cycling to print every sub menus. */
foreach($menu as $menuItem)
{
+ if(isset($lang->$moduleName->dividerMenu) and strpos($lang->$moduleName->dividerMenu, ",{$menuItem->name},") !== false) echo "";
if(isset($menuItem->hidden) && $menuItem->hidden) continue;
if($isMobile and empty($menuItem->link)) continue;
/* Init the these vars. */
+ $alias = isset($menuItem->alias) ? $menuItem->alias : '';
+ $subModule = isset($menuItem->subModule) ? explode(',', $menuItem->subModule) : array();
+ $class = isset($menuItem->class) ? $menuItem->class : '';
+ $active = '';
+ if($subModule and in_array($currentModule, $subModule)) $active = 'active';
+ if($alias and $moduleName == $currentModule and strpos(",$alias,", ",$currentMethod,") !== false) $active = 'active';
if($menuItem->link)
{
- $active = '';
- $float = isset($menuItem->float) ? $menuItem->float : '';
- $alias = '';
$target = '';
$module = '';
$method = '';
$link = commonModel::createMenuLink($menuItem);
if(is_array($menuItem->link))
{
- if(isset($menuItem->link['subModule']))
- {
- $subModules = explode(',', $menuItem->link['subModule']);
- if(in_array($currentModule, $subModules) and $float != 'right') $active = 'active';
- }
- if(isset($menuItem->link['alias'])) $alias = $menuItem->link['alias'];
if(isset($menuItem->link['target'])) $target = $menuItem->link['target'];
if(isset($menuItem->link['module'])) $module = $menuItem->link['module'];
if(isset($menuItem->link['method'])) $method = $menuItem->link['method'];
}
- if($float != 'right' and $module == $currentModule and ($method == $currentMethod or strpos(",$alias,", ",$currentMethod,") !== false)) $active = 'active';
+ if($module == $currentModule and ($method == $currentMethod or strpos(",$alias,", ",$currentMethod,") !== false)) $active = 'active';
- $menuItemHtml = "" . html::a($link, $menuItem->text, $target) . "\n";
- if($isMobile) $menuItemHtml = html::a($link, $menuItem->text, $target, "class='$active'") . "\n";
+ $menuItemHtml = "" . html::a($link, $menuItem->text, $target) . "\n";
+ if($isMobile) $menuItemHtml = html::a($link, $menuItem->text, $target, "class='$class $active'") . "\n";
echo $menuItemHtml;
}
else
{
- echo $isMobile ? $menuItem->text : "$menuItem->text\n";
+ echo $isMobile ? $menuItem->text : "$menuItem->text\n";
}
}
echo $isMobile ? '' : "\n";
@@ -1290,7 +1288,7 @@ EOD;
if(!empty($app->user->admin)) return true;
if($module == 'todo' and ($method == 'create' or $method == 'batchcreate')) return true;
- if($module == 'effort' and $method == 'batchcreate') return true;
+ if($module == 'effort' and ($method == 'batchcreate' or $method == 'createforobject')) return true;
// limited project
$limitedProject = false;
diff --git a/module/custom/model.php b/module/custom/model.php
index 8a48482aaa..358b27fa52 100644
--- a/module/custom/model.php
+++ b/module/custom/model.php
@@ -209,11 +209,12 @@ class customModel extends model
{
if(is_object($item)) $item = (array)$item;
- $label = '';
- $module = '';
- $method = '';
- $float = '';
- $fixed = '';
+ $label = '';
+ $module = '';
+ $method = '';
+ $class = '';
+ $subModule = '';
+ $alias = '';
$link = (is_array($item) and isset($item['link'])) ? $item['link'] : $item;
/* The variable of item has not link and is not link then ignore it. */
@@ -235,31 +236,28 @@ class customModel extends model
{
$itemLink = array('module' => $module, 'method' => $method);
if(isset($link[3])) $itemLink['vars'] = $link[3];
- if(is_array($item))
- {
- if(isset($item['subModule'])) $itemLink['subModule'] = $item['subModule'];
- if(isset($item['alias'])) $itemLink['alias'] = $item['alias'];
- if(isset($item['target'])) $itemLink['target'] = $item['target'];
- }
+ if(is_array($item) and isset($item['target'])) $itemLink['target'] = $item['target'];
}
if(is_array($item))
{
- if(isset($item['float'])) $float = $item['float'];
- if(isset($item['fixed'])) $fixed = $item['fixed'];
+ if(isset($item['class'])) $class = $item['class'];
+ if(isset($item['subModule'])) $subModule = $item['subModule'];
+ if(isset($item['alias'])) $alias = $item['alias'];
}
- $hidden = !$fixed && isset($customMenuMap[$name]) && isset($customMenuMap[$name]->hidden) && $customMenuMap[$name]->hidden;
+ $hidden = isset($customMenuMap[$name]) && isset($customMenuMap[$name]->hidden) && $customMenuMap[$name]->hidden;
if(strpos($name, 'QUERY') === 0 and !isset($customMenuMap[$name])) $hidden = true;
$menuItem = new stdclass();
$menuItem->name = $name;
$menuItem->link = $itemLink;
$menuItem->text = $label;
- $menuItem->order = $fixed ? -1 : (isset($customMenuMap[$name]) && isset($customMenuMap[$name]->order) ? $customMenuMap[$name]->order : $order++);
- if($float) $menuItem->float = $float;
- if($fixed) $menuItem->fixed = $fixed;
- if($hidden) $menuItem->hidden = $hidden;
+ $menuItem->order = (isset($customMenuMap[$name]) && isset($customMenuMap[$name]->order) ? $customMenuMap[$name]->order : $order++);
+ if($hidden) $menuItem->hidden = $hidden;
+ if($class) $menuItem->class = $class;
+ if($subModule)$menuItem->subModule = $subModule;
+ if($alias) $menuItem->alias = $alias;
if($isTutorialMode) $menuItem->tutorial = true;
/* Hidden menu by config in mobile. */
diff --git a/module/project/css/burn.css b/module/project/css/burn.css
index 71404cdc9f..8f8e93dccf 100644
--- a/module/project/css/burn.css
+++ b/module/project/css/burn.css
@@ -1,7 +1,3 @@
-.container {max-width: 950px!important;}
-.container .actions {margin-bottom: 10px; padding: 0}
-.container .actions > .text {padding: 5px 5px 5px 15px; line-height: 20px}
.mw-220px {max-width: 220px!important}
-#wrap h1{font-size:14px;}
#interval{margin-right:10px;}
.canvas-wrapper {padding: 15px; border: 1px solid #ddd;}
diff --git a/module/project/lang/en.php b/module/project/lang/en.php
index 8b72c65986..21017b2007 100644
--- a/module/project/lang/en.php
+++ b/module/project/lang/en.php
@@ -146,6 +146,7 @@ $lang->project->storySort = 'Sort Story';
$lang->project->importPlanStory = 'Create ' . $lang->projectCommon . ' success!\nImport the stories with the plan?';
$lang->project->iteration = 'Iteration';
$lang->project->iterationInfo = 'Iteration %s times';
+$lang->project->viewAll = 'View All';
/* 分组浏览。*/
$lang->project->allTasks = 'All';
diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php
index f139611ddb..9e84e05f4a 100644
--- a/module/project/lang/zh-cn.php
+++ b/module/project/lang/zh-cn.php
@@ -147,6 +147,7 @@ $lang->project->storySort = '需求排序';
$lang->project->importPlanStory = '创建' . $lang->projectCommon . '成功!\n是否导入计划关联的相关需求?';
$lang->project->iteration = '版本迭代';
$lang->project->iterationInfo = '迭代%s次';
+$lang->project->viewAll = '查看所有';
/* 分组浏览。*/
$lang->project->allTasks = '所有';
diff --git a/module/project/model.php b/module/project/model.php
index b353612eb1..c15a5e7127 100644
--- a/module/project/model.php
+++ b/module/project/model.php
@@ -78,9 +78,9 @@ class projectModel extends model
if($project and $project->type == 'ops')
{
unset($this->lang->project->menu->story);
- unset($this->lang->project->menu->bug);
- unset($this->lang->project->menu->build);
- unset($this->lang->project->menu->testtask);
+ unset($this->lang->project->subMenu->qa->bug);
+ unset($this->lang->project->subMenu->qa->build);
+ unset($this->lang->project->subMenu->qa->testtask);
}
if($projects and !isset($projects[$projectID]) and !$this->checkPriv($project))
@@ -118,6 +118,36 @@ class projectModel extends model
foreach($this->lang->project->menu as $key => $menu)
{
$replace = $projectID;
+
+ /* Replace for dropdown submenu. */
+ if(isset($this->lang->project->subMenu->$key))
+ {
+ $dropTitle = '';
+ $hasActive = false;
+ $replace = "';
+ $replace = "$dropTitle " . $replace;
+
+ $this->lang->project->menu->$key['class'] = 'dropdown';
+ if($hasActive) $this->lang->project->menu->$key['class'] .= ' active';
+ }
common::setMenuVars($this->lang->project->menu, $key, $replace);
}
}
diff --git a/www/js/zui/min.js b/www/js/zui/min.js
index 4906e4efbc..4ed85dc630 100644
--- a/www/js/zui/min.js
+++ b/www/js/zui/min.js
@@ -4,10026 +4,27 @@
* GitHub: https://github.com/easysoft/zui.git
* Copyright (c) 2018 cnezsoft.com; Licensed MIT
*/
-
-/* ========================================================================
- * ZUI: jquery.extensions.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, window, undefined) {
- 'use strict';
-
- /* Check jquery */
- if(typeof($) === 'undefined') throw new Error('ZUI requires jQuery');
-
- // ZUI shared object
- if(!$.zui) $.zui = function(obj) {
- if($.isPlainObject(obj)) {
- $.extend($.zui, obj);
- }
- };
-
- var MOUSE_BUTTON_CODES = {
- all: -1,
- left: 0,
- middle: 1,
- right: 2
- };
-
- var lastUuidAmend = 0;
- $.zui({
- uuid: function(asNumber) {
- var uuidNumber = (new Date()).getTime() * 1000 + (lastUuidAmend++) % 1000;
- return asNumber ? uuidNumber : uuidNumber.toString(36);
- },
-
- callEvent: function(func, event, proxy) {
- if($.isFunction(func)) {
- if(proxy !== undefined) {
- func = $.proxy(func, proxy);
- }
- var result = func(event);
- if(event) event.result = result;
- return !(result !== undefined && (!result));
- }
- return 1;
- },
-
- clientLang: function() {
- var lang;
- var config = window.config;
- if(typeof(config) != 'undefined' && config.clientLang) {
- lang = config.clientLang;
- }
- if(!lang) {
- var hl = $('html').attr('lang');
- lang = hl ? hl : (navigator.userLanguage || navigator.userLanguage || 'zh_cn');
- }
- return lang.replace('-', '_').toLowerCase();
- },
-
- strCode: function(str) {
- var code = 0;
- if(str && str.length) {
- for(var i = 0; i < str.length; ++i) {
- code += i * str.charCodeAt(i);
- }
- }
- return code;
- },
-
- getMouseButtonCode: function(mouseButton) {
- if(typeof mouseButton !== 'number') {
- mouseButton = MOUSE_BUTTON_CODES[mouseButton];
- }
- if(mouseButton === undefined || mouseButton === null) mouseButton = -1;
- return mouseButton;
- }
- });
-
- $.fn.callEvent = function(name, event, model) {
- var $this = $(this);
- var dotIndex = name.indexOf('.zui.');
- var shortName = dotIndex < 0 ? name : name.substring(0, dotIndex);
- var e = $.Event(shortName, event);
-
- if((model === undefined) && dotIndex > 0) {
- model = $this.data(name.substring(dotIndex + 1));
- }
-
- if(model && model.options) {
- var func = model.options[shortName];
- if($.isFunction(func)) {
- e.result = $.zui.callEvent(func, e, model);
- }
- }
- $this.trigger(e);
- return e;
- };
-
- $.fn.callComEvent = function(component, eventName, params) {
- if (params !== undefined && !$.isArray(params)) {
- params = [params];
- }
- var $this = this;
- var result = $this.triggerHandler(eventName, params);
-
- var eventCallback = component.options[eventName];
- if (eventCallback) {
- result = eventCallback.apply(component, params);
- }
- return result;
- };
-}(jQuery, window, undefined));
-
-
-/* ========================================================================
- * ZUI: typography.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($) {
- 'use strict';
-
- $.fn.fixOlPd = function(pd) {
- pd = pd || 10;
- return this.each(function() {
- var $ol = $(this);
- $ol.css('paddingLeft', Math.ceil(Math.log10($ol.children().length)) * pd + 10);
- });
- };
-
- $(function() {
- $('.ol-pd-fix,.article ol').fixOlPd();
- });
-}(jQuery));
-
-
-/* ========================================================================
- * Bootstrap: alert.js v3.0.0
- * http://twbs.github.com/bootstrap/javascript.html#alerts
- * ========================================================================
- * Copyright 2013 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // ALERT CLASS DEFINITION
- // ======================
-
- var dismiss = '[data-dismiss="alert"]'
- var zuiname = 'zui.alert';
-
- var Alert = function(el) {
- $(el).on('click', dismiss, this.close)
- }
-
- Alert.prototype.close = function(e) {
- var $this = $(this)
- var selector = $this.attr('data-target')
-
- if(!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
- }
-
- var $parent = $(selector)
-
- if(e) e.preventDefault()
-
- if(!$parent.length) {
- $parent = $this.hasClass('alert') ? $this : $this.parent()
- }
-
- $parent.trigger(e = $.Event('close.' + zuiname))
-
- if(e.isDefaultPrevented()) return
-
- $parent.removeClass('in')
-
- function removeElement() {
- $parent.trigger('closed.' + zuiname).remove()
- }
-
- $.support.transition && $parent.hasClass('fade') ?
- $parent
- .one($.support.transition.end, removeElement)
- .emulateTransitionEnd(150) :
- removeElement()
- }
-
-
- // ALERT PLUGIN DEFINITION
- // =======================
-
- var old = $.fn.alert
-
- $.fn.alert = function(option) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data(zuiname)
-
- if(!data) $this.data(zuiname, (data = new Alert(this)))
- if(typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.alert.Constructor = Alert
-
-
- // ALERT NO CONFLICT
- // =================
-
- $.fn.alert.noConflict = function() {
- $.fn.alert = old
- return this
- }
-
-
- // ALERT DATA-API
- // ==============
-
- $(document).on('click.' + zuiname + '.data-api', dismiss, Alert.prototype.close)
-
-}(window.jQuery);
-
-/* ========================================================================
- * ZUI: pager.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2017-2018 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, undefined) {
- 'use strict';
-
- var NAME = 'zui.pager'; // model name
-
- var DEFAULT_PAGER = {
- page: 1, // current page index
- recTotal: 0, // records total count
- recPerPage: 10, // records count per page
- };
-
- var LANG = {
- zh_cn: {
- prev: '上一页',
- next: '下一页',
- first: '第一页',
- last: '最后一页',
- goto: '跳转',
- pageOf: '第 {page} 页',
- totalPage: '共 {totalPage} 页',
- totalCount: '共 {recTotal} 项',
- pageSize: '每页 {recPerPage} 项',
- itemsRange: '第 {start} ~ {end} 项',
- pageOfTotal: '第 {page}/{totalPage} 页'
- },
- zh_tw: {
- prev: '上一頁',
- next: '下一頁',
- first: '第一頁',
- last: '最後一頁',
- goto: '跳轉',
- pageOf: '第 {page} 頁',
- totalPage: '共 {totalPage} 頁',
- totalCount: '共 {recTotal} 項',
- pageSize: '每頁 {recPerPage} 項',
- itemsRange: '第 {start} ~ {end} 項',
- pageOfTotal: '第 {page}/{totalPage} 頁'
- },
- en: {
- prev: 'Prev',
- next: 'Next',
- first: 'First',
- last: 'Last',
- goto: 'Goto',
- pageOf: 'Page {page}',
- totalPage: '{totalPage} pages',
- totalCount: '{recTotal} items',
- pageSize: '{recPerPage} items per page',
- itemsRange: 'From {start} to {end}',
- pageOfTotal: 'Page {page} of {totalPage}'
- }
- };
-
- // The pager model class
- var Pager = function(element, options) {
- var that = this;
- that.name = NAME;
- that.$ = $(element);
-
- options = that.options = $.extend({}, Pager.DEFAULTS, this.$.data(), options);
-
- var lang = options.lang || 'zh_cn';
- that.lang = $.isPlainObject(lang) ? ($.extend(true, {}, LANG[lang.lang || $.zui.clientLang()], lang)) : LANG[lang];
-
- that.state = {};
-
- that.set(options.page, options.recTotal, options.recPerPage, true);
-
- that.$.on('click', '.pager-goto-btn', function() {
- var $goto = $(this).closest('.pager-goto');
- var page = parseInt($goto.find('.pager-goto-input').val());
- if (page !== NaN) {
- that.set(page);
- }
- }).on('click', '.pager-item', function() {
- var page = $(this).data('page');
- if (typeof page === 'number' && page > 0) {
- that.set(page);
- }
- }).on('click', '.pager-size-menu [data-size]', function() {
- var size = $(this).data('size');
- if (typeof size === 'number' && size > 0) {
- that.set(-1, -1, size);
- }
- });
- };
-
- Pager.prototype.set = function(page, recTotal, recPerPage, notTiggerChange) {
- var that = this;
- if (typeof page === 'object' && page !== null) {
- recPerPage = page.recPerPage;
- recTotal = page.recTotal;
- page = page.page;
- }
- var state = that.state;
- if (!state) {
- state = $.extend({}, DEFAULT_PAGER);
- }
- var oldState = $.extend({}, state);
- if (typeof recPerPage === 'number' && recPerPage > 0) {
- state.recPerPage = recPerPage;
- }
- if (typeof recTotal === 'number' && recTotal >= 0) {
- state.recTotal = recTotal;
- }
- if (typeof page === 'number' && page >= 0) {
- state.page = page;
- }
- state.totalPage = (state.recTotal && state.recPerPage) ? (Math.ceil(state.recTotal / state.recPerPage)) : 1;
- state.page = Math.max(0, Math.min(state.page, state.totalPage));
- // stateRecCount is items count in current page
- state.pageRecCount = state.recTotal;
- if (state.page && state.recTotal) {
- if (state.page < state.totalPage) {
- state.pageRecCount = state.recPerPage;
- } else if (state.page > 1) {
- state.pageRecCount = state.recTotal - (state.recPerPage * (state.page - 1));
- }
- }
- state.skip = state.page > 1 ? ((state.page - 1) * state.recPerPage) : 0;
- state.start = state.skip + 1;
- state.end = state.skip + state.pageRecCount;
- state.prev = state.page > 1 ? (state.page - 1) : 0;
- state.next = state.page < state.totalPage ? (state.page + 1) : 0;
- that.state = state;
- if (!notTiggerChange && (oldState.page !== state.page || oldState.recTotal !== state.recTotal || oldState.recPerPage !== state.recPerPage)) {
- that.$.callComEvent(that, 'onPageChange', [state, oldState]);
- }
- return that.render();
- };
-
- Pager.prototype.createLinkItem = function(page, text, asAElement) {
- var that = this;
- if (text === undefined) {
- text = page;
- }
- var $ele = $('').attr('href', page ? that.createLink(page, that.state) : '###').html(text);
- if (!asAElement) {
- $ele = $('').append($ele).toggleClass('active', page === that.state.page).toggleClass('disabled', !page);
- }
- return $ele;
- };
-
- Pager.prototype.createNavItems = function(maxCount) {
- var that = this;
- var $nav = that.$;
- var pager = that.state;
- var totalPage = pager.totalPage;
- var page = pager.page;
- var appendItem = function(p, to) {
- if(p === false) {
- $nav.append(that.createLinkItem(0, to || that.options.navEllipsisItem));
- return;
- }
- if(to === undefined) to = p;
- for(var i = p; i <= to; ++i) {
- $nav.append(that.createLinkItem(i));
- }
- };
- if (maxCount === undefined) {
- maxCount = that.options.maxNavCount || 10;
- }
- appendItem(1);
- if(totalPage > 1) {
- if(totalPage <= maxCount) {
- appendItem(2, totalPage);
- }
- else if(page < (maxCount - 2)) {
- appendItem(2, maxCount - 2);
- appendItem(false);
- appendItem(totalPage);
- }
- else if(page > (totalPage - maxCount + 2)) {
- appendItem(false);
- appendItem((totalPage - maxCount + 2), totalPage);
- }
- else {
- appendItem(false);
- appendItem(page - Math.ceil((maxCount-4)/2), page + Math.floor((maxCount-4)/2));
- appendItem(false);
- appendItem(totalPage);
- }
- }
- };
-
- Pager.prototype.createGoto = function() {
- var that = this;
- var pager = this.state;
- var $goto = $('');
- return $goto;
- };
-
- Pager.prototype.createSizeMenu = function() {
- var that = this;
- var pager = this.state;
- var $menu = $('');
- var options = that.options.pageSizeOptions;
- if (typeof options === 'string') {
- options = options.split(',');
- }
- for (var i = 0; i < options.length; ++i) {
- var size = options[i];
- if (typeof size === 'string') {
- size = parseInt(size);
- }
- var $li = $('' + size + '').toggleClass('active', size === pager.recPerPage);
- $menu.append($li);
- }
- return $('').addClass(that.options.menuDirection).append($menu);
- };
-
- Pager.prototype.createElement = function(element, $pager, pager) {
- var that = this;
- var createLinkItem= $.proxy(that.createLinkItem, that);
- var lang = that.lang;
- switch (element) {
- case 'prev':
- return createLinkItem(pager.prev, lang.prev);
- case 'prev_icon':
- return createLinkItem(pager.prev, '');
- case 'next':
- return createLinkItem(pager.next, lang.next);
- case 'next_icon':
- return createLinkItem(pager.next, '');
- case 'first':
- return createLinkItem(1, lang.first, true);
- case 'first_icon':
- return createLinkItem(1, '', true);
- case 'last':
- return createLinkItem(pager.totalPage, lang.last, true);
- case 'last_icon':
- return createLinkItem(pager.totalPage, '', true);
- case 'space':
- case '|':
- return $('');
- case 'nav':
- case 'pages':
- that.createNavItems();
- return;
- case 'total_text':
- return $(('').format(pager));
- case 'page_text':
- return $(('').format(pager));
- case 'total_page_text':
- return $(('').format(pager));
- case 'page_of_total_text':
- return $(('').format(pager));
- case 'page_size_text':
- return $(('').format(pager));
- case 'items_range_text':
- return $(('').format(pager));
- case 'goto':
- return that.createGoto();
- case 'size_menu':
- return that.createSizeMenu();
- default:
- return $('').html(element);
- }
- };
-
- Pager.prototype.createLink = function(page, pager) {
- if (page === undefined) {
- page = this.state.page;
- }
- if (pager === undefined) {
- pager = this.state;
- }
- var linkCreator = this.options.linkCreator;
- if (typeof linkCreator === 'string') {
- return linkCreator.format($.extend({}, pager, {page: page}));
- } else if ($.isFunction(linkCreator)) {
- return linkCreator(page, pager);
- }
- return '#page=' + page;
- };
-
- Pager.prototype.render = function(elements) {
- var that = this;
- var state = that.state;
- var createElement = that.options.elementCreator || that.createElement;
- var isMapperCreator = $.isPlainObject(createElement);
-
- elements = elements || that.elements || that.options.elements;
- if (typeof elements == 'string') {
- elements = elements.split(',');
- }
- that.elements = elements;
-
- that.$.empty();
-
- for(var i = 0; i < elements.length; ++i) {
- var element = $.trim(elements[i]);
- var creator = isMapperCreator ? (createElement[element] || createElement) : createElement;
- var $element = creator.call(that, element, that.$, state);
- if ($element === false) {
- $element = that.createElement(element, that.$, state);
- }
- if ($element instanceof $) {
- if ($element[0].tagName !== 'LI') {
- $element = $('').append($element);
- }
- that.$.append($element);
- }
- }
-
- // Fix page item border
- var $lastItem = null;
- that.$.children('li').each(function() {
- var $li = $(this);
- var isItem = !!$li.children('.pager-item').length;
- if ($lastItem) {
- $lastItem.toggleClass('pager-item-right', !isItem);
- } else {
- if (isItem) {
- $li.addClass('pager-item-left');
- }
- }
- $lastItem = isItem ? $li : null;
- });
- if ($lastItem) {
- $lastItem.addClass('pager-item-right');
- }
-
- that.$.callComEvent(that, 'onRender', [state]);
- return that;
- };
-
- // default options
- Pager.DEFAULTS = $.extend({
- elements: ['first_icon', 'prev_icon', 'pages', 'next_icon', 'last_icon', 'page_of_total_text', 'items_range_text', 'total_text'],
- prevIcon: 'icon-double-angle-left',
- nextIcon: 'icon-double-angle-right',
- firstIcon: 'icon-step-backward',
- lastIcon: 'icon-step-forward',
- navEllipsisItem: '',
- maxNavCount: 10,
- menuDirection: 'dropdown', // or dropup
- pageSizeOptions: [10, 20, 30, 50, 100],
- // onPageChange: null
- }, DEFAULT_PAGER);
-
- // Extense jquery element
- $.fn.pager = function(option) {
- return this.each(function() {
- var $this = $(this);
- var data = $this.data(NAME);
- var options = typeof option == 'object' && option;
-
- if(!data) $this.data(NAME, (data = new Pager(this, options)));
-
- if(typeof option == 'string') data[option]();
- });
- };
-
- Pager.NAME = NAME;
-
- $.fn.pager.Constructor = Pager;
-
- // Auto call pager after document load complete
- $(function() {
- $('[data-ride="pager"]').pager();
- });
-}(jQuery, undefined));
-
-
-/* ========================================================================
- * Bootstrap: tab.js v3.0.0
- * http://twbs.github.com/bootstrap/javascript.html#tabs
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // TAB CLASS DEFINITION
- // ====================
-
- var zuiname = 'zui.tab'
- var Tab = function(element) {
- this.element = $(element)
- }
-
- Tab.prototype.show = function() {
- var $this = this.element
- var $ul = $this.closest('ul:not(.dropdown-menu)')
- var selector = $this.attr('data-target') || $this.attr('data-tab')
-
- if(!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- if($this.parent('li').hasClass('active')) return
-
- var previous = $ul.find('.active:last a')[0]
- var e = $.Event('show.' + zuiname, {
- relatedTarget: previous
- })
-
- $this.trigger(e)
-
- if(e.isDefaultPrevented()) return
-
- var $target = $(selector)
-
- this.activate($this.parent('li'), $ul)
- this.activate($target, $target.parent(), function() {
- $this.trigger({
- type: 'shown.' + zuiname,
- relatedTarget: previous
- })
- })
- }
-
- Tab.prototype.activate = function(element, container, callback) {
- var $active = container.find('> .active')
- var transition = callback && $.support.transition && $active.hasClass('fade')
-
- function next() {
- $active
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
-
- element.addClass('active')
-
- if(transition) {
- element[0].offsetWidth // reflow for transition
- element.addClass('in')
- } else {
- element.removeClass('fade')
- }
-
- if(element.parent('.dropdown-menu')) {
- element.closest('li.dropdown').addClass('active')
- }
-
- callback && callback()
- }
-
- transition ?
- $active
- .one($.support.transition.end, next)
- .emulateTransitionEnd(150) :
- next()
-
- $active.removeClass('in')
- }
-
-
- // TAB PLUGIN DEFINITION
- // =====================
-
- var old = $.fn.tab
-
- $.fn.tab = function(option) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data(zuiname)
-
- if(!data) $this.data(zuiname, (data = new Tab(this)))
- if(typeof option == 'string') data[option]()
- })
- }
-
- $.fn.tab.Constructor = Tab
-
-
- // TAB NO CONFLICT
- // ===============
-
- $.fn.tab.noConflict = function() {
- $.fn.tab = old
- return this
- }
-
-
- // TAB DATA-API
- // ============
-
- $(document).on('click.zui.tab.data-api', '[data-toggle="tab"], [data-tab]', function(e) {
- e.preventDefault()
- $(this).tab('show')
- })
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * Bootstrap: transition.js v3.2.0
- * http://getbootstrap.com/javascript/#transitions
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2011-2014 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
- // ============================================================
-
- function transitionEnd() {
- var el = document.createElement('bootstrap')
-
- var transEndEventNames = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd otransitionend',
- transition: 'transitionend'
- }
-
- for(var name in transEndEventNames) {
- if(el.style[name] !== undefined) {
- return {
- end: transEndEventNames[name]
- }
- }
- }
-
- return false // explicit for ie8 ( ._.)
- }
-
- // http://blog.alexmaccaw.com/css-transitions
- $.fn.emulateTransitionEnd = function(duration) {
- var called = false
- var $el = this
- $(this).one('bsTransitionEnd', function() {
- called = true
- })
- var callback = function() {
- if(!called) $($el).trigger($.support.transition.end)
- }
- setTimeout(callback, duration)
- return this
- }
-
- $(function() {
- $.support.transition = transitionEnd()
-
- if(!$.support.transition) return
-
- $.event.special.bsTransitionEnd = {
- bindType: $.support.transition.end,
- delegateType: $.support.transition.end,
- handle: function(e) {
- if($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
- }
- }
- })
-
-}(jQuery);
-
-
-/* ========================================================================
- * Bootstrap: collapse.js v3.0.0
- * http://twbs.github.com/bootstrap/javascript.html#collapse
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- var zuiname = 'zui.collapse'
-
- // COLLAPSE PUBLIC CLASS DEFINITION
- // ================================
-
- var Collapse = function(element, options) {
- this.$element = $(element)
- this.options = $.extend({}, Collapse.DEFAULTS, options)
- this.transitioning = null
-
- if(this.options.parent) this.$parent = $(this.options.parent)
- if(this.options.toggle) this.toggle()
- }
-
- Collapse.DEFAULTS = {
- toggle: true
- }
-
- Collapse.prototype.dimension = function() {
- var hasWidth = this.$element.hasClass('width')
- return hasWidth ? 'width' : 'height'
- }
-
- Collapse.prototype.show = function() {
- if(this.transitioning || this.$element.hasClass('in')) return
-
- var startEvent = $.Event('show.' + zuiname)
- this.$element.trigger(startEvent)
- if(startEvent.isDefaultPrevented()) return
-
- var actives = this.$parent && this.$parent.find('.in')
-
- if(actives && actives.length) {
- var hasData = actives.data(zuiname)
- if(hasData && hasData.transitioning) return
- actives.collapse('hide')
- hasData || actives.data(zuiname, null)
- }
-
- var dimension = this.dimension()
-
- this.$element
- .removeClass('collapse')
- .addClass('collapsing')[dimension](0)
-
- this.transitioning = 1
-
- var complete = function() {
- this.$element
- .removeClass('collapsing')
- .addClass('in')[dimension]('auto')
- this.transitioning = 0
- this.$element.trigger('shown.' + zuiname)
- }
-
- if(!$.support.transition) return complete.call(this)
-
- var scrollSize = $.camelCase(['scroll', dimension].join('-'))
-
- this.$element
- .one($.support.transition.end, $.proxy(complete, this))
- .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
- }
-
- Collapse.prototype.hide = function() {
- if(this.transitioning || !this.$element.hasClass('in')) return
-
- var startEvent = $.Event('hide.' + zuiname)
- this.$element.trigger(startEvent)
- if(startEvent.isDefaultPrevented()) return
-
- var dimension = this.dimension()
-
- this.$element[dimension](this.$element[dimension]())[0].offsetHeight
-
- this.$element
- .addClass('collapsing')
- .removeClass('collapse')
- .removeClass('in')
-
- this.transitioning = 1
-
- var complete = function() {
- this.transitioning = 0
- this.$element
- .trigger('hidden.' + zuiname)
- .removeClass('collapsing')
- .addClass('collapse')
- }
-
- if(!$.support.transition) return complete.call(this)
-
- this.$element[dimension](0)
- .one($.support.transition.end, $.proxy(complete, this))
- .emulateTransitionEnd(350)
- }
-
- Collapse.prototype.toggle = function() {
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
- }
-
-
- // COLLAPSE PLUGIN DEFINITION
- // ==========================
-
- var old = $.fn.collapse
-
- $.fn.collapse = function(option) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data(zuiname)
- var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
-
- if(!data) $this.data(zuiname, (data = new Collapse(this, options)))
- if(typeof option == 'string') data[option]()
- })
- }
-
- $.fn.collapse.Constructor = Collapse
-
-
- // COLLAPSE NO CONFLICT
- // ====================
-
- $.fn.collapse.noConflict = function() {
- $.fn.collapse = old
- return this
- }
-
-
- // COLLAPSE DATA-API
- // =================
-
- $(document).on('click.' + zuiname + '.data-api', '[data-toggle=collapse]', function(e) {
- var $this = $(this),
- href
- var target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
- var $target = $(target)
- var data = $target.data(zuiname)
- var option = data ? 'toggle' : $this.data()
- var parent = $this.attr('data-parent')
- var $parent = parent && $(parent)
-
- if(!data || !data.transitioning) {
- if($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
- $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
- }
-
- $target.collapse(option)
- })
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * ZUI: device.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function(window, $) {
- 'use strict';
- var desktopLg = 1200,
- desktop = 992,
- tablet = 768;
-
- var $window = $(window);
-
- var resetCssClass = function() {
- var width = $window.width();
- $('html').toggleClass('screen-desktop', width >= desktop && width < desktopLg)
- .toggleClass('screen-desktop-wide', width >= desktopLg)
- .toggleClass('screen-tablet', width >= tablet && width < desktop)
- .toggleClass('screen-phone', width < tablet)
- .toggleClass('device-mobile', width < desktop)
- .toggleClass('device-desktop', width >= desktop);
- };
-
- var classNames = '';
- var userAgent = navigator.userAgent;
- if (userAgent.match(/(iPad|iPhone|iPod)/i)) {
- classNames += ' os-ios';
- } else if (userAgent.match(/android/i)) {
- classNames += ' os-android';
- } else if (userAgent.match(/Win/i)) {
- classNames += ' os-windows';
- } else if (userAgent.match(/Mac/i)) {
- classNames += ' os-mac';
- } else if (userAgent.match(/Linux/i)) {
- classNames += ' os-linux';
- } else if (userAgent.match(/X11/i)) {
- classNames += ' os-unix';
- }
- if ('ontouchstart' in document.documentElement) {
- classNames += ' is-touchable';
- }
- $('html').addClass(classNames);
-
- $window.resize(resetCssClass);
- resetCssClass();
-}(window, jQuery));
-
-
-/* ========================================================================
- * ZUI: browser.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($) {
- 'use strict';
-
- var browseHappyTip = {
- 'zh_cn': '您的浏览器版本过低,无法体验所有功能,建议升级或者更换浏览器。 了解更多...',
- 'zh_tw': '您的瀏覽器版本過低,無法體驗所有功能,建議升級或者更换瀏覽器。了解更多...',
- 'en': 'Your browser is too old, it has been unable to experience the colorful internet. We strongly recommend that you upgrade a better one. Learn more...'
- };
-
- // The browser modal class
- var Browser = function() {
- var ie = this.isIE() || this.isIE10() || false;
- if(ie) {
- for(var i = 10; i > 5; i--) {
- if(this.isIE(i)) {
- ie = i;
- break;
- }
- }
- }
-
- this.ie = ie;
-
- this.cssHelper();
- };
-
- // Append CSS class to html tag
- Browser.prototype.cssHelper = function() {
- var ie = this.ie,
- $html = $('html');
- $html.toggleClass('ie', ie)
- .removeClass('ie-6 ie-7 ie-8 ie-9 ie-10');
- if(ie) {
- $html.addClass('ie-' + ie)
- .toggleClass('gt-ie-7 gte-ie-8 support-ie', ie >= 8)
- .toggleClass('lte-ie-7 lt-ie-8 outdated-ie', ie < 8)
- .toggleClass('gt-ie-8 gte-ie-9', ie >= 9)
- .toggleClass('lte-ie-8 lt-ie-9', ie < 9)
- .toggleClass('gt-ie-9 gte-ie-10', ie >= 10)
- .toggleClass('lte-ie-9 lt-ie-10', ie < 10);
- }
- };
-
- // Show browse happy tip
- Browser.prototype.tip = function(showCoontent) {
- var $browseHappy = $('#browseHappyTip');
- if(!$browseHappy.length) {
- $browseHappy = $('');
- $browseHappy.prependTo('body');
- }
-
- $browseHappy.find('.content').html(showCoontent || this.browseHappyTip || browseHappyTip[$.zui.clientLang() || 'zh_cn']);
- };
-
- // Detect it is IE, can given a version
- Browser.prototype.isIE = function(version) {
- if(version === 10) return this.isIE10();
- var b = document.createElement('b');
- b.innerHTML = '';
- return b.getElementsByTagName('i').length === 1;
- };
-
- // Detect ie 10 with hack
- Browser.prototype.isIE10 = function() {
- return (/*@cc_on!@*/false);
- };
-
- $.zui({
- browser: new Browser()
- });
-
- $(function() {
- if(!$('body').hasClass('disabled-browser-tip')) {
- if($.zui.browser.ie && $.zui.browser.ie < 8) {
- $.zui.browser.tip();
- }
- }
- });
-}(jQuery));
-
-
-/* ========================================================================
- * ZUI: date.js
- * Date polyfills
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function() {
- 'use strict';
-
- /**
- * Ticks of a whole day
- * @type {number}
- */
- Date.ONEDAY_TICKS = 24 * 3600 * 1000;
-
- /**
- * Format date to a string
- *
- * @param string format
- * @return string
- */
- if(!Date.prototype.format) {
- Date.prototype.format = function(format) {
- var date = {
- 'M+': this.getMonth() + 1,
- 'd+': this.getDate(),
- 'h+': this.getHours(),
- 'm+': this.getMinutes(),
- 's+': this.getSeconds(),
- 'q+': Math.floor((this.getMonth() + 3) / 3),
- 'S+': this.getMilliseconds()
- };
- if(/(y+)/i.test(format)) {
- format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
- }
- for(var k in date) {
- if(new RegExp('(' + k + ')').test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ('00' + date[k]).substr(('' + date[k]).length));
- }
- }
- return format;
- };
- }
-
- /**
- * Add milliseconds to the date
- * @param {number} value
- */
- if(!Date.prototype.addMilliseconds) {
- Date.prototype.addMilliseconds = function(value) {
- this.setTime(this.getTime() + value);
- return this;
- };
- }
-
-
- /**
- * Add days to the date
- * @param {number} days
- */
- if(!Date.prototype.addDays) {
- Date.prototype.addDays = function(days) {
- this.addMilliseconds(days * Date.ONEDAY_TICKS);
- return this;
- };
- }
-
-
- /**
- * Clone a new date instane from the date
- * @return {Date}
- */
- if(!Date.prototype.clone) {
- Date.prototype.clone = function() {
- var date = new Date();
- date.setTime(this.getTime());
- return date;
- };
- }
-
-
- /**
- * Judge the year is in a leap year
- * @param {integer} year
- * @return {Boolean}
- */
- if(!Date.isLeapYear) {
- Date.isLeapYear = function(year) {
- return(((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
- };
- }
-
- if(!Date.getDaysInMonth) {
- /**
- * Get days number of the date
- * @param {integer} year
- * @param {integer} month
- * @return {integer}
- */
- Date.getDaysInMonth = function(year, month) {
- return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
- };
- }
-
-
- /**
- * Judge the date is in a leap year
- * @return {Boolean}
- */
- if(!Date.prototype.isLeapYear) {
- Date.prototype.isLeapYear = function() {
- return Date.isLeapYear(this.getFullYear());
- };
- }
-
-
- /**
- * Clear time part of the date
- * @return {date}
- */
- if(!Date.prototype.clearTime) {
- Date.prototype.clearTime = function() {
- this.setHours(0);
- this.setMinutes(0);
- this.setSeconds(0);
- this.setMilliseconds(0);
- return this;
- };
- }
-
-
- /**
- * Get days of this month of the date
- * @return {integer}
- */
- if(!Date.prototype.getDaysInMonth) {
- Date.prototype.getDaysInMonth = function() {
- return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
- };
- }
-
-
- /**
- * Add months to the date
- * @param {date} value
- */
- if(!Date.prototype.addMonths) {
- Date.prototype.addMonths = function(value) {
- var n = this.getDate();
- this.setDate(1);
- this.setMonth(this.getMonth() + value);
- this.setDate(Math.min(n, this.getDaysInMonth()));
- return this;
- };
- }
-
-
- /**
- * Get last week day of the date
- * @param {integer} day
- * @return {date}
- */
- if(!Date.prototype.getLastWeekday) {
- Date.prototype.getLastWeekday = function(day) {
- day = day || 1;
-
- var d = this.clone();
- while(d.getDay() != day) {
- d.addDays(-1);
- }
- d.clearTime();
- return d;
- };
- }
-
-
- /**
- * Judge the date is same day as another date
- * @param {date} date
- * @return {Boolean}
- */
- if(!Date.prototype.isSameDay) {
- Date.prototype.isSameDay = function(date) {
- return date.toDateString() === this.toDateString();
- };
- }
-
-
- /**
- * Judge the date is in same week as another date
- * @param {date} date
- * @return {Boolean}
- */
- if(!Date.prototype.isSameWeek) {
- Date.prototype.isSameWeek = function(date) {
- var weekStart = this.getLastWeekday();
- var weekEnd = weekStart.clone().addDays(7);
- return date >= weekStart && date < weekEnd;
- };
- }
-
-
- /**
- * Judge the date is in same year as another date
- * @param {date} date
- * @return {Boolean}
- */
- if(!Date.prototype.isSameYear) {
- Date.prototype.isSameYear = function(date) {
- return this.getFullYear() === date.getFullYear();
- };
- }
-
- /**
- * Create an date instance with string, timestamp or date instance
- * @param {Date|String|Number} date
- * @return {Date}
- */
- if (!Date.create) {
- Date.create = function(date) {
- if (!(date instanceof Date)) {
- if (typeof date === 'number' && date < 10000000000) {
- date *= 1000;
- }
- date = new Date(date);
- }
- return date;
- };
- }
-
- if (!Date.timestamp) {
- Date.timestamp = function(date) {
- if (typeof date === 'number') {
- if (date < 10000000000) {
- date *= 1000;
- }
- } else {
- date = Date.create(date).getTime();
- }
- return date;
- };
- }
-}());
-
-
-/* ========================================================================
- * ZUI: string.js
- * String Polyfill.
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function() {
- 'use strict';
-
- /**
- * Format string with argument list or object
- * @param {object | arguments} args
- * @return {String}
- */
- if(!String.prototype.format) {
- String.prototype.format = function(args) {
- var result = this;
- if(arguments.length > 0) {
- var reg;
- if(arguments.length <= 2 && typeof(args) == 'object') {
- for(var key in args) {
- if(args[key] !== undefined) {
- reg = new RegExp('(' + (arguments[1] ? arguments[1].replace('0', key) : '{' + key + '}') + ')', 'g');
- result = result.replace(reg, args[key]);
- }
- }
- } else {
- for(var i = 0; i < arguments.length; i++) {
- if(arguments[i] !== undefined) {
- reg = new RegExp('({[' + i + ']})', 'g');
- result = result.replace(reg, arguments[i]);
- }
- }
- }
- }
- return result;
- };
- }
-
- /**
- * Judge the string is a integer number
- *
- * @access public
- * @return bool
- */
- if(!String.prototype.isNum) {
- String.prototype.isNum = function(s) {
- if(s !== null) {
- var r, re;
- re = /\d*/i;
- r = s.match(re);
- return(r == s) ? true : false;
- }
- return false;
- };
- }
-
- if(!String.prototype.endsWith) {
- String.prototype.endsWith = function(searchString, position) {
- var subjectString = this.toString();
- if(position === undefined || position > subjectString.length) {
- position = subjectString.length;
- }
- position -= searchString.length;
- var lastIndex = subjectString.indexOf(searchString, position);
- return lastIndex !== -1 && lastIndex === position;
- };
- }
-
- if(!String.prototype.startsWith) {
- String.prototype.startsWith = function(searchString, position) {
- position = position || 0;
- return this.lastIndexOf(searchString, position) === position;
- };
- }
-
- if(!String.prototype.includes) {
- String.prototype.includes = function() {
- return String.prototype.indexOf.apply(this, arguments) !== -1;
- };
- }
-
-})();
-
-
-/* ========================================================================
- * Resize: resize.js [Version: 1.1]
- * http://benalman.com/projects/jquery-resize-plugin/
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * opyright (c) 2010 "Cowboy" Ben Alman
- * Dual licensed under the MIT and GPL licenses.
- * http://benalman.com/about/license/
- * ======================================================================== */
-
-
-/*!
+!function(t,e,i){"use strict";if("undefined"==typeof t)throw new Error("ZUI requires jQuery");t.zui||(t.zui=function(e){t.isPlainObject(e)&&t.extend(t.zui,e)});var s={all:-1,left:0,middle:1,right:2},n=0;t.zui({uuid:function(t){var e=1e3*(new Date).getTime()+n++%1e3;return t?e:e.toString(36)},callEvent:function(e,s,n){if(t.isFunction(e)){n!==i&&(e=t.proxy(e,n));var a=e(s);return s&&(s.result=a),!(a!==i&&!a)}return 1},clientLang:function(){var i,s=e.config;if("undefined"!=typeof s&&s.clientLang&&(i=s.clientLang),!i){var n=t("html").attr("lang");i=n?n:navigator.userLanguage||navigator.userLanguage||"zh_cn"}return i.replace("-","_").toLowerCase()},strCode:function(t){var e=0;if(t&&t.length)for(var i=0;i0&&(n=a.data(e.substring(o+1))),n&&n.options){var h=n.options[r];t.isFunction(h)&&(l.result=t.zui.callEvent(h,l,n))}return a.trigger(l),l},t.fn.callComEvent=function(e,s,n){n===i||t.isArray(n)||(n=[n]);var a=this,o=a.triggerHandler(s,n),r=e.options[s];return r&&(o=r.apply(e,n)),o}}(jQuery,window,void 0),function(t){"use strict";t.fn.fixOlPd=function(e){return e=e||10,this.each(function(){var i=t(this);i.css("paddingLeft",Math.ceil(Math.log10(i.children().length))*e+10)})},t(function(){t(".ol-pd-fix,.article ol").fixOlPd()})}(jQuery),+function(t){"use strict";var e='[data-dismiss="alert"]',i="zui.alert",s=function(i){t(i).on("click",e,this.close)};s.prototype.close=function(e){function s(){o.trigger("closed."+i).remove()}var n=t(this),a=n.attr("data-target");a||(a=n.attr("href"),a=a&&a.replace(/.*(?=#[^\s]*$)/,""));var o=t(a);e&&e.preventDefault(),o.length||(o=n.hasClass("alert")?n:n.parent()),o.trigger(e=t.Event("close."+i)),e.isDefaultPrevented()||(o.removeClass("in"),t.support.transition&&o.hasClass("fade")?o.one(t.support.transition.end,s).emulateTransitionEnd(150):s())};var n=t.fn.alert;t.fn.alert=function(e){return this.each(function(){var n=t(this),a=n.data(i);a||n.data(i,a=new s(this)),"string"==typeof e&&a[e].call(n)})},t.fn.alert.Constructor=s,t.fn.alert.noConflict=function(){return t.fn.alert=n,this},t(document).on("click."+i+".data-api",e,s.prototype.close)}(window.jQuery),function(t,e){"use strict";var i="zui.pager",s={page:1,recTotal:0,recPerPage:10},n={zh_cn:{prev:"上一页",next:"下一页",first:"第一页",last:"最后一页","goto":"跳转",pageOf:"第 {page} 页",totalPage:"共 {totalPage} 页",totalCount:"共 {recTotal} 项",pageSize:"每页 {recPerPage} 项",itemsRange:"第 {start} ~ {end} 项",pageOfTotal:"第 {page}/{totalPage} 页"},zh_tw:{prev:"上一頁",next:"下一頁",first:"第一頁",last:"最後一頁","goto":"跳轉",pageOf:"第 {page} 頁",totalPage:"共 {totalPage} 頁",totalCount:"共 {recTotal} 項",pageSize:"每頁 {recPerPage} 項",itemsRange:"第 {start} ~ {end} 項",pageOfTotal:"第 {page}/{totalPage} 頁"},en:{prev:"Prev",next:"Next",first:"First",last:"Last","goto":"Goto",pageOf:"Page {page}",totalPage:"{totalPage} pages",totalCount:"{recTotal} items",pageSize:"{recPerPage} items per page",itemsRange:"From {start} to {end}",pageOfTotal:"Page {page} of {totalPage}"}},a=function(e,s){var o=this;o.name=i,o.$=t(e),s=o.options=t.extend({},a.DEFAULTS,this.$.data(),s);var r=s.lang||"zh_cn";o.lang=t.isPlainObject(r)?t.extend(!0,{},n[r.lang||t.zui.clientLang()],r):n[r],o.state={},o.set(s.page,s.recTotal,s.recPerPage,!0),o.$.on("click",".pager-goto-btn",function(){var e=t(this).closest(".pager-goto"),i=parseInt(e.find(".pager-goto-input").val());NaN!==i&&o.set(i)}).on("click",".pager-item",function(){var e=t(this).data("page");"number"==typeof e&&e>0&&o.set(e)}).on("click",".pager-size-menu [data-size]",function(){var e=t(this).data("size");"number"==typeof e&&e>0&&o.set(-1,-1,e)})};a.prototype.set=function(e,i,n,a){var o=this;"object"==typeof e&&null!==e&&(n=e.recPerPage,i=e.recTotal,e=e.page);var r=o.state;r||(r=t.extend({},s));var l=t.extend({},r);return"number"==typeof n&&n>0&&(r.recPerPage=n),"number"==typeof i&&i>=0&&(r.recTotal=i),"number"==typeof e&&e>=0&&(r.page=e),r.totalPage=r.recTotal&&r.recPerPage?Math.ceil(r.recTotal/r.recPerPage):1,r.page=Math.max(0,Math.min(r.page,r.totalPage)),r.pageRecCount=r.recTotal,r.page&&r.recTotal&&(r.page1&&(r.pageRecCount=r.recTotal-r.recPerPage*(r.page-1))),r.skip=r.page>1?(r.page-1)*r.recPerPage:0,r.start=r.skip+1,r.end=r.skip+r.pageRecCount,r.prev=r.page>1?r.page-1:0,r.next=r.page').attr("href",i?a.createLink(i,a.state):"###").html(s);return n||(o=t("").append(o).toggleClass("active",i===a.state.page).toggleClass("disabled",!i)),o},a.prototype.createNavItems=function(t){var i=this,s=i.$,n=i.state,a=n.totalPage,o=n.page,r=function(t,n){if(t===!1)return void s.append(i.createLinkItem(0,n||i.options.navEllipsisItem));n===e&&(n=t);for(var a=t;a<=n;++a)s.append(i.createLinkItem(a))};t===e&&(t=i.options.maxNavCount||10),r(1),a>1&&(a<=t?r(2,a):oa-t+2?(r(!1),r(a-t+2,a)):(r(!1),r(o-Math.ceil((t-4)/2),o+Math.floor((t-4)/2)),r(!1),r(a)))},a.prototype.createGoto=function(){var e=this,i=this.state,s=t('");return s},a.prototype.createSizeMenu=function(){var e=this,i=this.state,s=t(''),n=e.options.pageSizeOptions;"string"==typeof n&&(n=n.split(","));for(var a=0;a'+o+"").toggleClass("active",o===i.recPerPage);s.append(r)}return t('').addClass(e.options.menuDirection).append(s)},a.prototype.createElement=function(e,i,s){var n=this,a=t.proxy(n.createLinkItem,n),o=n.lang;switch(e){case"prev":return a(s.prev,o.prev);case"prev_icon":return a(s.prev,'');case"next":return a(s.next,o.next);case"next_icon":return a(s.next,'');case"first":return a(1,o.first,!0);case"first_icon":return a(1,'',!0);case"last":return a(s.totalPage,o.last,!0);case"last_icon":return a(s.totalPage,'',!0);case"space":case"|":return t('');case"nav":case"pages":return void n.createNavItems();case"total_text":return t(('").format(s));case"page_text":return t(('").format(s));case"total_page_text":return t(('").format(s));case"page_of_total_text":return t(('").format(s));case"page_size_text":return t(('").format(s));case"items_range_text":return t(('").format(s));case"goto":return n.createGoto();case"size_menu":return n.createSizeMenu();default:return t("").html(e)}},a.prototype.createLink=function(i,s){i===e&&(i=this.state.page),s===e&&(s=this.state);var n=this.options.linkCreator;return"string"==typeof n?n.format(t.extend({},s,{page:i})):t.isFunction(n)?n(i,s):"#page="+i},a.prototype.render=function(e){var i=this,s=i.state,n=i.options.elementCreator||i.createElement,a=t.isPlainObject(n);e=e||i.elements||i.options.elements,"string"==typeof e&&(e=e.split(",")),i.elements=e,i.$.empty();for(var o=0;o").append(h)),i.$.append(h))}var c=null;return i.$.children("li").each(function(){var e=t(this),i=!!e.children(".pager-item").length;c?c.toggleClass("pager-item-right",!i):i&&e.addClass("pager-item-left"),c=i?e:null}),c&&c.addClass("pager-item-right"),i.$.callComEvent(i,"onRender",[s]),i},a.DEFAULTS=t.extend({elements:["first_icon","prev_icon","pages","next_icon","last_icon","page_of_total_text","items_range_text","total_text"],prevIcon:"icon-double-angle-left",nextIcon:"icon-double-angle-right",firstIcon:"icon-step-backward",lastIcon:"icon-step-forward",navEllipsisItem:'',maxNavCount:10,menuDirection:"dropdown",pageSizeOptions:[10,20,30,50,100]},s),t.fn.pager=function(e){return this.each(function(){var s=t(this),n=s.data(i),o="object"==typeof e&&e;n||s.data(i,n=new a(this,o)),"string"==typeof e&&n[e]()})},a.NAME=i,t.fn.pager.Constructor=a,t(function(){t('[data-ride="pager"]').pager()})}(jQuery,void 0),+function(t){"use strict";var e="zui.tab",i=function(e){this.element=t(e)};i.prototype.show=function(){var i=this.element,s=i.closest("ul:not(.dropdown-menu)"),n=i.attr("data-target")||i.attr("data-tab");if(n||(n=i.attr("href"),n=n&&n.replace(/.*(?=#[^\s]*$)/,"")),!i.parent("li").hasClass("active")){var a=s.find(".active:last a")[0],o=t.Event("show."+e,{relatedTarget:a});if(i.trigger(o),!o.isDefaultPrevented()){var r=t(n);this.activate(i.parent("li"),s),this.activate(r,r.parent(),function(){i.trigger({type:"shown."+e,relatedTarget:a})})}}},i.prototype.activate=function(e,i,s){function n(){a.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),e.addClass("active"),o?(e[0].offsetWidth,e.addClass("in")):e.removeClass("fade"),e.parent(".dropdown-menu")&&e.closest("li.dropdown").addClass("active"),s&&s()}var a=i.find("> .active"),o=s&&t.support.transition&&a.hasClass("fade");o?a.one(t.support.transition.end,n).emulateTransitionEnd(150):n(),a.removeClass("in")};var s=t.fn.tab;t.fn.tab=function(s){return this.each(function(){var n=t(this),a=n.data(e);a||n.data(e,a=new i(this)),"string"==typeof s&&a[s]()})},t.fn.tab.Constructor=i,t.fn.tab.noConflict=function(){return t.fn.tab=s,this},t(document).on("click.zui.tab.data-api",'[data-toggle="tab"], [data-tab]',function(e){e.preventDefault(),t(this).tab("show")})}(window.jQuery),+function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return{end:e[i]};return!1}t.fn.emulateTransitionEnd=function(e){var i=!1,s=this;t(this).one("bsTransitionEnd",function(){i=!0});var n=function(){i||t(s).trigger(t.support.transition.end)};return setTimeout(n,e),this},t(function(){t.support.transition=e(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(e){if(t(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(t){"use strict";var e="zui.collapse",i=function(e,s){this.$element=t(e),this.options=t.extend({},i.DEFAULTS,s),this.transitioning=null,this.options.parent&&(this.$parent=t(this.options.parent)),this.options.toggle&&this.toggle()};i.DEFAULTS={toggle:!0},i.prototype.dimension=function(){var t=this.$element.hasClass("width");return t?"width":"height"},i.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var i=t.Event("show."+e);if(this.$element.trigger(i),!i.isDefaultPrevented()){var s=this.$parent&&this.$parent.find(".in");if(s&&s.length){var n=s.data(e);if(n&&n.transitioning)return;s.collapse("hide"),n||s.data(e,null)}var a=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[a](0),this.transitioning=1;var o=function(){this.$element.removeClass("collapsing").addClass("in")[a]("auto"),this.transitioning=0,this.$element.trigger("shown."+e)};if(!t.support.transition)return o.call(this);var r=t.camelCase(["scroll",a].join("-"));this.$element.one(t.support.transition.end,t.proxy(o,this)).emulateTransitionEnd(350)[a](this.$element[0][r])}}},i.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var i=t.Event("hide."+e);if(this.$element.trigger(i),!i.isDefaultPrevented()){var s=this.dimension();this.$element[s](this.$element[s]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var n=function(){this.transitioning=0,this.$element.trigger("hidden."+e).removeClass("collapsing").addClass("collapse")};return t.support.transition?void this.$element[s](0).one(t.support.transition.end,t.proxy(n,this)).emulateTransitionEnd(350):n.call(this)}}},i.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var s=t.fn.collapse;t.fn.collapse=function(s){return this.each(function(){var n=t(this),a=n.data(e),o=t.extend({},i.DEFAULTS,n.data(),"object"==typeof s&&s);a||n.data(e,a=new i(this,o)),"string"==typeof s&&a[s]()})},t.fn.collapse.Constructor=i,t.fn.collapse.noConflict=function(){return t.fn.collapse=s,this},t(document).on("click."+e+".data-api","[data-toggle=collapse]",function(i){var s,n=t(this),a=n.attr("data-target")||i.preventDefault()||(s=n.attr("href"))&&s.replace(/.*(?=#[^\s]+$)/,""),o=t(a),r=o.data(e),l=r?"toggle":n.data(),h=n.attr("data-parent"),c=h&&t(h);r&&r.transitioning||(c&&c.find('[data-toggle=collapse][data-parent="'+h+'"]').not(n).addClass("collapsed"),n[o.hasClass("in")?"addClass":"removeClass"]("collapsed")),o.collapse(l)})}(window.jQuery),function(t,e){"use strict";var i=1200,s=992,n=768,a=e(t),o=function(){var t=a.width();e("html").toggleClass("screen-desktop",t>=s&&t=i).toggleClass("screen-tablet",t>=n&&t=s)},r="",l=navigator.userAgent;l.match(/(iPad|iPhone|iPod)/i)?r+=" os-ios":l.match(/android/i)?r+=" os-android":l.match(/Win/i)?r+=" os-windows":l.match(/Mac/i)?r+=" os-mac":l.match(/Linux/i)?r+=" os-linux":l.match(/X11/i)&&(r+=" os-unix"),"ontouchstart"in document.documentElement&&(r+=" is-touchable"),e("html").addClass(r),a.resize(o),o()}(window,jQuery),function(t){"use strict";var e={zh_cn:'您的浏览器版本过低,无法体验所有功能,建议升级或者更换浏览器。 了解更多...',zh_tw:'您的瀏覽器版本過低,無法體驗所有功能,建議升級或者更换瀏覽器。了解更多...',en:'Your browser is too old, it has been unable to experience the colorful internet. We strongly recommend that you upgrade a better one. Learn more...'},i=function(){var t=this.isIE()||this.isIE10()||!1;if(t)for(var e=10;e>5;e--)if(this.isIE(e)){t=e;break}this.ie=t,this.cssHelper()};i.prototype.cssHelper=function(){var e=this.ie,i=t("html");i.toggleClass("ie",e).removeClass("ie-6 ie-7 ie-8 ie-9 ie-10"),e&&i.addClass("ie-"+e).toggleClass("gt-ie-7 gte-ie-8 support-ie",e>=8).toggleClass("lte-ie-7 lt-ie-8 outdated-ie",e<8).toggleClass("gt-ie-8 gte-ie-9",e>=9).toggleClass("lte-ie-8 lt-ie-9",e<9).toggleClass("gt-ie-9 gte-ie-10",e>=10).toggleClass("lte-ie-9 lt-ie-10",e<10)},i.prototype.tip=function(i){var s=t("#browseHappyTip");s.length||(s=t(''),s.prependTo("body")),s.find(".content").html(i||this.browseHappyTip||e[t.zui.clientLang()||"zh_cn"])},i.prototype.isIE=function(t){if(10===t)return this.isIE10();var e=document.createElement("b");return e.innerHTML="",1===e.getElementsByTagName("i").length},i.prototype.isIE10=function(){return!1},t.zui({browser:new i}),t(function(){t("body").hasClass("disabled-browser-tip")||t.zui.browser.ie&&t.zui.browser.ie<8&&t.zui.browser.tip()})}(jQuery),function(){"use strict";Date.ONEDAY_TICKS=864e5,Date.prototype.format||(Date.prototype.format=function(t){var e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),"S+":this.getMilliseconds()};/(y+)/i.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(var i in e)new RegExp("("+i+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[i]:("00"+e[i]).substr((""+e[i]).length)));return t}),Date.prototype.addMilliseconds||(Date.prototype.addMilliseconds=function(t){return this.setTime(this.getTime()+t),this}),Date.prototype.addDays||(Date.prototype.addDays=function(t){return this.addMilliseconds(t*Date.ONEDAY_TICKS),this}),Date.prototype.clone||(Date.prototype.clone=function(){var t=new Date;return t.setTime(this.getTime()),t}),Date.isLeapYear||(Date.isLeapYear=function(t){return t%4===0&&t%100!==0||t%400===0}),Date.getDaysInMonth||(Date.getDaysInMonth=function(t,e){return[31,Date.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]}),Date.prototype.isLeapYear||(Date.prototype.isLeapYear=function(){return Date.isLeapYear(this.getFullYear())}),Date.prototype.clearTime||(Date.prototype.clearTime=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this}),Date.prototype.getDaysInMonth||(Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth())}),Date.prototype.addMonths||(Date.prototype.addMonths=function(t){var e=this.getDate();return this.setDate(1),this.setMonth(this.getMonth()+t),this.setDate(Math.min(e,this.getDaysInMonth())),this}),Date.prototype.getLastWeekday||(Date.prototype.getLastWeekday=function(t){t=t||1;for(var e=this.clone();e.getDay()!=t;)e.addDays(-1);return e.clearTime(),e}),Date.prototype.isSameDay||(Date.prototype.isSameDay=function(t){return t.toDateString()===this.toDateString()}),Date.prototype.isSameWeek||(Date.prototype.isSameWeek=function(t){var e=this.getLastWeekday(),i=e.clone().addDays(7);return t>=e&&t0){var i;if(arguments.length<=2&&"object"==typeof t)for(var s in t)void 0!==t[s]&&(i=new RegExp("("+(arguments[1]?arguments[1].replace("0",s):"{"+s+"}")+")","g"),e=e.replace(i,t[s]));else for(var n=0;ni.length)&&(e=i.length),e-=t.length;var s=i.indexOf(t,e);return s!==-1&&s===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.lastIndexOf(t,e)===e}),String.prototype.includes||(String.prototype.includes=function(){return String.prototype.indexOf.apply(this,arguments)!==-1})}(),/*!
* jQuery resize event - v1.1
* http://benalman.com/projects/jquery-resize-plugin/
* Copyright (c) 2010 "Cowboy" Ben Alman
* MIT & GPL http://benalman.com/about/license/
*/
-
-// Script: jQuery resize event
-//
-// *Version: 1.1, Last updated: 3/14/2010*
-//
-// Project Home - http://benalman.com/projects/jquery-resize-plugin/
-// GitHub - http://github.com/cowboy/jquery-resize/
-// Source - http://github.com/cowboy/jquery-resize/raw/master/jquery.ba-resize.js
-// (Minified) - http://github.com/cowboy/jquery-resize/raw/master/jquery.ba-resize.min.js (1.0kb)
-//
-// About: License
-//
-// Copyright (c) 2010 "Cowboy" Ben Alman,
-// Dual licensed under the MIT and GPL licenses.
-// http://benalman.com/about/license/
-//
-// About: Examples
-//
-// This working example, complete with fully commented code, illustrates a few
-// ways in which this plugin can be used.
-//
-// resize event - http://benalman.com/code/projects/jquery-resize/examples/resize/
-//
-// About: Support and Testing
-//
-// Information about what version or versions of jQuery this plugin has been
-// tested with, what browsers it has been tested in, and where the unit tests
-// reside (so you can test it yourself).
-//
-// jQuery Versions - 1.3.2, 1.4.1, 1.4.2
-// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1.
-// Unit Tests - http://benalman.com/code/projects/jquery-resize/unit/
-//
-// About: Release History
-//
-// 1.1 - (3/14/2010) Fixed a minor bug that was causing the event to trigger
-// immediately after bind in some circumstances. Also changed $.fn.data
-// to $.data to improve performance.
-// 1.0 - (2/10/2010) Initial release
-
-(function($, window, undefined) {
- '$:nomunge'; // Used by YUI compressor.
-
- // A jQuery object containing all non-window elements to which the resize
- // event is bound.
- var elems = $([]),
-
- // Extend $.resize if it already exists, otherwise create it.
- jq_resize = $.resize = $.extend($.resize, {}),
-
- timeout_id,
-
- // Reused strings.
- str_setTimeout = 'setTimeout',
- str_resize = 'resize',
- str_data = str_resize + '-special-event',
- str_delay = 'delay',
- str_throttle = 'throttleWindow';
-
- // Property: jQuery.resize.delay
- //
- // The numeric interval (in milliseconds) at which the resize event polling
- // loop executes. Defaults to 250.
-
- jq_resize[str_delay] = 250;
-
- // Property: jQuery.resize.throttleWindow
- //
- // Throttle the native window object resize event to fire no more than once
- // every milliseconds. Defaults to true.
- //
- // Because the window object has its own resize event, it doesn't need to be
- // provided by this plugin, and its execution can be left entirely up to the
- // browser. However, since certain browsers fire the resize event continuously
- // while others do not, enabling this will throttle the window resize event,
- // making event behavior consistent across all elements in all browsers.
- //
- // While setting this property to false will disable window object resize
- // event throttling, please note that this property must be changed before any
- // window object resize event callbacks are bound.
-
- jq_resize[str_throttle] = true;
-
- // Event: resize event
- //
- // Fired when an element's width or height changes. Because browsers only
- // provide this event for the window element, for other elements a polling
- // loop is initialized, running every milliseconds
- // to see if elements' dimensions have changed. You may bind with either
- // .resize( fn ) or .bind( "resize", fn ), and unbind with .unbind( "resize" ).
- //
- // Usage:
- //
- // > jQuery('selector').bind( 'resize', function(e) {
- // > // element's width or height has changed!
- // > ...
- // > });
- //
- // Additional Notes:
- //
- // * The polling loop is not created until at least one callback is actually
- // bound to the 'resize' event, and this single polling loop is shared
- // across all elements.
- //
- // Double firing issue in jQuery 1.3.2:
- //
- // While this plugin works in jQuery 1.3.2, if an element's event callbacks
- // are manually triggered via .trigger( 'resize' ) or .resize() those
- // callbacks may double-fire, due to limitations in the jQuery 1.3.2 special
- // events system. This is not an issue when using jQuery 1.4+.
- //
- // > // While this works in jQuery 1.4+
- // > $(elem).css({ width: new_w, height: new_h }).resize();
- // >
- // > // In jQuery 1.3.2, you need to do this:
- // > var elem = $(elem);
- // > elem.css({ width: new_w, height: new_h });
- // > elem.data( 'resize-special-event', { width: elem.width(), height: elem.height() } );
- // > elem.resize();
-
- $.event.special[str_resize] = {
-
- // Called only when the first 'resize' event callback is bound per element.
- setup: function() {
- // Since window has its own native 'resize' event, return false so that
- // jQuery will bind the event using DOM methods. Since only 'window'
- // objects have a .setTimeout method, this should be a sufficient test.
- // Unless, of course, we're throttling the 'resize' event for window.
- if(!jq_resize[str_throttle] && this[str_setTimeout]) {
- return false;
- }
-
- var elem = $(this);
-
- // Add this element to the list of internal elements to monitor.
- elems = elems.add(elem);
-
- // Initialize data store on the element.
- $.data(this, str_data, {
- w: elem.width(),
- h: elem.height()
- });
-
- // If this is the first element added, start the polling loop.
- if(elems.length === 1) {
- loopy();
- }
- },
-
- // Called only when the last 'resize' event callback is unbound per element.
- teardown: function() {
- // Since window has its own native 'resize' event, return false so that
- // jQuery will unbind the event using DOM methods. Since only 'window'
- // objects have a .setTimeout method, this should be a sufficient test.
- // Unless, of course, we're throttling the 'resize' event for window.
- if(!jq_resize[str_throttle] && this[str_setTimeout]) {
- return false;
- }
-
- var elem = $(this);
-
- // Remove this element from the list of internal elements to monitor.
- elems = elems.not(elem);
-
- // Remove any data stored on the element.
- elem.removeData(str_data);
-
- // If this is the last element removed, stop the polling loop.
- if(!elems.length) {
- clearTimeout(timeout_id);
- }
- },
-
- // Called every time a 'resize' event callback is bound per element (new in
- // jQuery 1.4).
- add: function(handleObj) {
- // Since window has its own native 'resize' event, return false so that
- // jQuery doesn't modify the event object. Unless, of course, we're
- // throttling the 'resize' event for window.
- if(!jq_resize[str_throttle] && this[str_setTimeout]) {
- return false;
- }
-
- var old_handler;
-
- // The new_handler function is executed every time the event is triggered.
- // This is used to update the internal element data store with the width
- // and height when the event is triggered manually, to avoid double-firing
- // of the event callback. See the "Double firing issue in jQuery 1.3.2"
- // comments above for more information.
-
- function new_handler(e, w, h) {
- var elem = $(this),
- data = $.data(this, str_data) || {};
-
- // If called from the polling loop, w and h will be passed in as
- // arguments. If called manually, via .trigger( 'resize' ) or .resize(),
- // those values will need to be computed.
- data.w = w !== undefined ? w : elem.width();
- data.h = h !== undefined ? h : elem.height();
-
- old_handler.apply(this, arguments);
- };
-
- // This may seem a little complicated, but it normalizes the special event
- // .add method between jQuery 1.4/1.4.1 and 1.4.2+
- if($.isFunction(handleObj)) {
- // 1.4, 1.4.1
- old_handler = handleObj;
- return new_handler;
- } else {
- // 1.4.2+
- old_handler = handleObj.handler;
- handleObj.handler = new_handler;
- }
- }
-
- };
-
- function loopy() {
-
- // Start the polling loop, asynchronously.
- timeout_id = window[str_setTimeout](function() {
-
- // Iterate over all elements to which the 'resize' event is bound.
- elems.each(function() {
- var elem = $(this),
- width = elem.width(),
- height = elem.height(),
- data = $.data(this, str_data);
-
- // If element size has changed since the last time, update the element
- // data store and trigger the 'resize' event.
- if(width !== data.w || height !== data.h) {
- elem.trigger(str_resize, [data.w = width, data.h = height]);
- }
-
- });
-
- // Loop.
- loopy();
-
- }, jq_resize[str_delay]);
-
- };
-
-})(jQuery, this);
-
-
-/* ========================================================================
- * ZUI: storeb.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function(window, $) {
- 'use strict';
-
- var lsName = 'localStorage';
- var storage,
- dataset,
- pageName = 'page_' + window.location.pathname + window.location.search;
-
- /* The Store object */
- var Store = function() {
- this.slience = true;
- try {
- if((lsName in window) && window[lsName] && window[lsName].setItem) {
- this.enable = true;
- storage = window[lsName];
- }
- } catch(e){}
- if(!this.enable) {
- dataset = {};
- storage = {
- getLength: function() {
- var length = 0;
- $.each(dataset, function() {
- length++;
- });
- return length;
- },
- key: function(index) {
- var key, i = 0;
- $.each(dataset, function(k) {
- if(i === index) {
- key = k;
- return false;
- }
- i++;
- });
- return key;
- },
- removeItem: function(key) {
- delete dataset[key];
- },
- getItem: function(key) {
- return dataset[key];
- },
- setItem: function(key, val) {
- dataset[key] = val;
- },
- clear: function() {
- dataset = {};
- }
- };
- }
- this.storage = storage;
- this.page = this.get(pageName, {});
- };
-
- /* Save page data */
- Store.prototype.pageSave = function() {
- if($.isEmptyObject(this.page)) {
- this.remove(pageName);
- } else {
- var forDeletes = [],
- i;
- for(i in this.page) {
- var val = this.page[i];
- if(val === null)
- forDeletes.push(i);
- }
- for(i = forDeletes.length - 1; i >= 0; i--) {
- delete this.page[forDeletes[i]];
- }
- this.set(pageName, this.page);
- }
- };
-
- /* Remove page data item */
- Store.prototype.pageRemove = function(key) {
- if(typeof this.page[key] != 'undefined') {
- this.page[key] = null;
- this.pageSave();
- }
- };
-
- /* Clear page data */
- Store.prototype.pageClear = function() {
- this.page = {};
- this.pageSave();
- };
-
- /* Get page data */
- Store.prototype.pageGet = function(key, defaultValue) {
- var val = this.page[key];
- return(defaultValue !== undefined && (val === null || val === undefined)) ? defaultValue : val;
- };
-
- /* Set page data */
- Store.prototype.pageSet = function(objOrKey, val) {
- if($.isPlainObject(objOrKey)) {
- $.extend(true, this.page, objOrKey);
- } else {
- this.page[this.serialize(objOrKey)] = val;
- }
- this.pageSave();
- };
-
- /* Check enable status */
- Store.prototype.check = function() {
- if(!this.enable) {
- if(!this.slience) throw new Error('Browser not support localStorage or enable status been set true.');
- }
- return this.enable;
- };
-
- /* Get length */
- Store.prototype.length = function() {
- if(this.check()) {
- return storage.getLength ? storage.getLength() : storage.length;
- }
- return 0;
- };
-
- /* Remove item with browser localstorage native method */
- Store.prototype.removeItem = function(key) {
- storage.removeItem(key);
- return this;
- };
-
- /* Remove item with browser localstorage native method, same as removeItem */
- Store.prototype.remove = function(key) {
- return this.removeItem(key);
- };
-
- /* Get item value with browser localstorage native method, and without deserialize */
- Store.prototype.getItem = function(key) {
- return storage.getItem(key);
- };
-
- /* Get item value and deserialize it, if value is null and defaultValue been given then return defaultValue */
- Store.prototype.get = function(key, defaultValue) {
- var val = this.deserialize(this.getItem(key));
- if(typeof val === 'undefined' || val === null) {
- if(typeof defaultValue !== 'undefined') {
- return defaultValue;
- }
- }
- return val;
- };
-
- /* Get item key by index and deserialize it */
- Store.prototype.key = function(index) {
- return storage.key(index);
- };
-
- /* Set item value with browser localstorage native method, and without serialize filter */
- Store.prototype.setItem = function(key, val) {
- storage.setItem(key, val);
- return this;
- };
-
- /* Set item value, serialize it if the given value is not an string */
- Store.prototype.set = function(key, val) {
- if(val === undefined) return this.remove(key);
- this.setItem(key, this.serialize(val));
- return this;
- };
-
- /* Clear all items with browser localstorage native method */
- Store.prototype.clear = function() {
- storage.clear();
- return this;
- };
-
- /* Iterate all items with callback */
- Store.prototype.forEach = function(callback) {
- var length = this.length();
- for(var i = length - 1; i >= 0; i--) {
- var key = storage.key(i);
- callback(key, this.get(key));
- }
- return this;
- };
-
- /* Get all items and set value in an object. */
- Store.prototype.getAll = function() {
- var all = {};
- this.forEach(function(key, val) {
- all[key] = val;
- });
-
- return all;
- };
-
- /* Serialize value with JSON.stringify */
- Store.prototype.serialize = function(value) {
- if(typeof value === 'string') return value;
- return JSON.stringify(value);
- };
-
- /* Deserialize value, with JSON.parse if the given value is not a string */
- Store.prototype.deserialize = function(value) {
- if(typeof value !== 'string') return undefined;
- try {
- return JSON.parse(value);
- } catch(e) {
- return value || undefined;
- }
- };
-
- $.zui({
- store: new Store()
- });
-}(window, jQuery));
-
-
-/* ========================================================================
- * ZUI: searchbox.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($) {
- 'use strict';
-
- var NAME = 'zui.searchBox'; // modal name
-
- // The searchbox modal class
- var SearchBox = function(element, options) {
- var that = this;
- that.name = name;
- that.$ = $(element);
-
- that.options = options = $.extend({}, SearchBox.DEFAULTS, that.$.data(), options);
-
- // Initialize here
- var $input = that.$.is(options.inputSelector) ? that.$ : that.$.find(options.inputSelector);
- if ($input.length) {
- var clearChangeTimer = function() {
- if (that.changeTimer) {
- clearTimeout(that.changeTimer);
- that.changeTimer = null;
- }
- };
-
- var handleChange = function() {
- clearChangeTimer();
- var value = that.getSearch();
- if (value !== that.lastValue) {
- var isEmpty = value === '';
- $input.toggleClass('empty', isEmpty);
- that.$.callComEvent(that, 'onSearchChange', [value, isEmpty]);
- that.lastValue = value;
- }
- };
-
- that.$input = $input = $input.first();
- that.lastValue = that.getSearch();
-
- $input.on(options.listenEvent, function(params) {
- that.changeTimer = setTimeout(function() {
- handleChange();
- }, options.changeDelay);
- }).on('focus', function(e) {
- $input.addClass('focus');
- that.$.callComEvent(that, 'onFocus', [e]);
- }).on('blur', function(e) {
- $input.removeClass('focus');
- that.$.callComEvent(that, 'onBlur', [e]);
- }).on('keydown', function(e) {
- var handled = 0;
- var keyCode = e.which;
- if (keyCode === 27 && options.escToClear) { // esc
- this.setSearch('', true);
- handleChange();
- handled = 1;
- } else if (keyCode === 13 && options.onPressEnter) {
- handleChange();
- that.$.callComEvent(that, 'onPressEnter', [e]);
- }
- var onKeyDownResult = that.$.callComEvent(that, 'onKeyDown', [e]);
- if (onKeyDownResult === false) {
- handled = 1;
- }
- if (handled) {
- e.preventDefault();
- }
- });
-
- that.$.on('click', '.search-clear-btn', function(e) {
- that.setSearch('', true);
- handleChange();
- e.preventDefault();
- });
-
- handleChange();
- } else {
- console.error('ZUI: search box init error, cannot find search box input element.');
- }
- };
-
- // default options
- SearchBox.DEFAULTS = {
- inputSelector: 'input[type="search"],input[type="text"]',
- listenEvent: 'change input paste',
- changeDelay: 500,
-
- // onKeyDown: null,
- // onFocus: null,
- // onBlur: null,
- // onSearchChange: null,
- // onPressEnter: null,
- // escToClear: true
- };
-
- // Get current search string
- SearchBox.prototype.getSearch = function() {
- return this.$input && $.trim(this.$input.val());
- };
-
- // Set current search string
- SearchBox.prototype.setSearch = function(value, notTriggerChange) {
- var $input = this.$input;
- if ($input) {
- $input.val(value);
- if (!notTriggerChange) {
- $input.trigger('change');
- }
- }
- };
-
- // Focus input element
- SearchBox.prototype.focus = function() {
- this.$input && this.$input.focus();
- };
-
- // Extense jquery element
- $.fn.searchBox = function(option) {
- return this.each(function() {
- var $this = $(this);
- var data = $this.data(NAME);
- var options = typeof option == 'object' && option;
-
- if(!data) $this.data(NAME, (data = new SearchBox(this, options)));
-
- if(typeof option == 'string') data[option]();
- });
- };
-
- SearchBox.NAME = NAME;
-
- $.fn.searchBox.Constructor = SearchBox;
-}(jQuery));
-
-
-/* ========================================================================
- * ZUI: draggable.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, document) {
- 'use strict';
-
- var NAME = 'zui.draggable',
- DEFAULTS = {
- // selector: '',
- container: 'body',
- move: true
- // mouseButton: -1 // 0, 1, 2, -1, all, left, right, middle
- };
- var idIncrementer = 0;
-
- var Draggable = function(element, options) {
- var that = this;
- that.$ = $(element);
- that.id = idIncrementer++;
- that.options = $.extend({}, DEFAULTS, that.$.data(), options);
- that.init();
- };
-
- Draggable.DEFAULTS = DEFAULTS;
- Draggable.NAME = NAME;
-
- Draggable.prototype.init = function() {
- var that = this,
- $root = that.$,
- BEFORE = 'before',
- DRAG = 'drag',
- FINISH = 'finish',
- eventSuffix = '.' + NAME + '.' + that.id,
- mouseDownEvent = 'mousedown' + eventSuffix,
- mouseUpEvent = 'mouseup' + eventSuffix,
- mouseMoveEvent = 'mousemove' + eventSuffix,
- setting = that.options,
- selector = setting.selector,
- handle = setting.handle,
- $ele = $root,
- isMoveFunc = $.isFunction(setting.move),
- startPos,
- cPos,
- startOffset,
- mousePos,
- moved;
-
- var mouseMove = function(event) {
- var mX = event.pageX,
- mY = event.pageY;
- moved = true;
- var dragPos = {
- left: mX - startOffset.x,
- top: mY - startOffset.y
- };
-
- $ele.removeClass('drag-ready').addClass('dragging');
- if(setting.move) {
- if (isMoveFunc) {
- setting.move(dragPos, $ele);
- } else {
- $ele.css(dragPos);
- }
- }
-
- setting[DRAG] && setting[DRAG]({
- event: event,
- element: $ele,
- startOffset: startOffset,
- pos: dragPos,
- offset: {
- x: mX - startPos.x,
- y: mY - startPos.y
- },
- smallOffset: {
- x: mX - mousePos.x,
- y: mY - mousePos.y
- }
- });
- mousePos.x = mX;
- mousePos.y = mY;
-
- if(setting.stopPropagation) {
- event.stopPropagation();
- }
- };
-
- var mouseUp = function(event) {
- $(document).off(eventSuffix);
- if(!moved) {
- $ele.removeClass('drag-ready');
- return;
- }
- var endPos = {
- left: event.pageX - startOffset.x,
- top: event.pageY - startOffset.y
- };
- $ele.removeClass('drag-ready dragging');
- if(setting.move) {
- if (isMoveFunc) {
- setting.move(endPos, $ele);
- } else {
- $ele.css(endPos);
- }
- }
-
- setting[FINISH] && setting[FINISH]({
- event: event,
- element: $ele,
- startOffset: startOffset,
- pos: endPos,
- offset: {
- x: event.pageX - startPos.x,
- y: event.pageY - startPos.y
- },
- smallOffset: {
- x: event.pageX - mousePos.x,
- y: event.pageY - mousePos.y
- }
- });
- event.preventDefault();
- if(setting.stopPropagation) {
- event.stopPropagation();
- }
- };
-
- var mouseDown = function(event) {
- var mouseButton = $.zui.getMouseButtonCode(setting.mouseButton);
- if(mouseButton > -1 && event.button !== mouseButton) {
- return;
- }
-
- var $mouseDownEle = $(this);
- if(selector) {
- $ele = handle ? $mouseDownEle.closest(selector) : $mouseDownEle;
- }
-
- if(setting[BEFORE]) {
- var isSure = setting[BEFORE]({
- event: event,
- element: $ele
- });
- if(isSure === false) return;
- }
-
- var $container = $(setting.container),
- pos = $ele.offset();
- cPos = $container.offset();
- startPos = {
- x: event.pageX,
- y: event.pageY
- };
- startOffset = {
- x: event.pageX - pos.left + cPos.left,
- y: event.pageY - pos.top + cPos.top
- };
- mousePos = $.extend({}, startPos);
- moved = false;
-
- $ele.addClass('drag-ready');
- event.preventDefault();
-
- if(setting.stopPropagation) {
- event.stopPropagation();
- }
-
- $(document).on(mouseMoveEvent, mouseMove).on(mouseUpEvent, mouseUp);
- };
-
- if(handle) {
- $root.on(mouseDownEvent, handle, mouseDown);
- } else if(selector) {
- $root.on(mouseDownEvent, selector, mouseDown);
- } else {
- $root.on(mouseDownEvent, mouseDown);
- }
- };
-
- Draggable.prototype.destroy = function() {
- var eventSuffix = '.' + NAME + '.' + this.id;
- this.$.off(eventSuffix);
- $(document).off(eventSuffix);
- this.$.data(NAME, null);
- };
-
- $.fn.draggable = function(option) {
- return this.each(function() {
- var $this = $(this);
- var data = $this.data(NAME);
- var options = typeof option == 'object' && option;
-
- if(!data) $this.data(NAME, (data = new Draggable(this, options)));
- if(typeof option == 'string') data[option]();
- });
- };
-
- $.fn.draggable.Constructor = Draggable;
-}(jQuery, document));
-
-
-/* ========================================================================
- * ZUI: droppable.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, document, Math) {
- 'use strict';
-
- var NAME = 'zui.droppable',
- DEFAULTS = {
- // container: '',
- // selector: '',
- // handle: '',
- // flex: false,
- // nested: false,
- target: '.droppable-target',
- deviation: 5,
- sensorOffsetX: 0,
- sensorOffsetY: 0,
- // mouseButton: -1 // 0, 1, 2, -1, all, left, right, middle
- };
- var idIncrementer = 0;
-
- var Droppable = function(element, options) {
- var that = this;
- that.id = idIncrementer++;
- that.$ = $(element);
- that.options = $.extend({}, DEFAULTS, that.$.data(), options);
- that.init();
- };
-
- Droppable.DEFAULTS = DEFAULTS;
- Droppable.NAME = NAME;
-
- Droppable.prototype.trigger = function(name, params) {
- return $.zui.callEvent(this.options[name], params, this);
- };
-
- Droppable.prototype.init = function() {
- var that = this,
- $root = that.$,
- setting = that.options,
- deviation = setting.deviation,
- eventSuffix = '.' + NAME + '.' + that.id,
- mouseDownEvent = 'mousedown' + eventSuffix,
- mouseUpEvent = 'mouseup' + eventSuffix,
- mouseMoveEvent = 'mousemove' + eventSuffix,
- selector = setting.selector,
- handle = setting.handle,
- flex = setting.flex,
- container = setting.container,
- canMoveHere = setting.canMoveHere,
- $ele = $root,
- isMouseDown = false,
- $container = container ? $(setting.container).first() : (selector ? $root : $('body')),
- $targets,
- $target,
- $shadow,
- isIn,
- isSelf,
- oldCssPosition,
- startOffset,
- startMouseOffset,
- containerOffset,
- clickOffset,
- mouseOffset,
- lastMouseOffset,
- mouseDownBackEventCall;
-
- var mouseMove = function(event) {
- if(!isMouseDown) return;
-
- mouseOffset = {left: event.pageX, top: event.pageY};
-
- // ignore small move
- if(Math.abs(mouseOffset.left - startMouseOffset.left) < deviation && Math.abs(mouseOffset.top - startMouseOffset.top) < deviation) return;
-
- if($shadow === null) // create shadow
- {
- var cssPosition = $container.css('position');
- if(cssPosition != 'absolute' && cssPosition != 'relative' && cssPosition != 'fixed') {
- oldCssPosition = cssPosition;
- $container.css('position', 'relative');
- }
-
- $shadow = $ele.clone().removeClass('drag-from').addClass('drag-shadow').css({
- position: 'absolute',
- width: $ele.outerWidth(),
- transition: 'none'
- }).appendTo($container);
- $ele.addClass('dragging');
-
- that.trigger('start', {
- event: event,
- element: $ele
- });
- }
-
- var offset = {
- left: mouseOffset.left - clickOffset.left,
- top: mouseOffset.top - clickOffset.top
- };
- var position = {
- left: offset.left - containerOffset.left,
- top: offset.top - containerOffset.top
- };
- $shadow.css(position);
- $.extend(lastMouseOffset, mouseOffset);
-
- var isNew = false;
- isIn = false;
-
- if(!flex) {
- $targets.removeClass('drop-to');
- }
-
- var $newTarget = null;
- $targets.each(function() {
- var t = $(this),
- tPos = t.offset(),
- tW = t.outerWidth(),
- tH = t.outerHeight(),
- tX = tPos.left + setting.sensorOffsetX,
- tY = tPos.top + setting.sensorOffsetY;
-
- if(mouseOffset.left > tX && mouseOffset.top > tY && mouseOffset.left < (tX + tW) && mouseOffset.top < (tY + tH)) {
- if($newTarget) $newTarget.removeClass('drop-to');
- $newTarget = t;
- if(!setting.nested) return false;
- }
- });
-
- if($newTarget) {
- isIn = true;
- var id = $newTarget.data('id');
- if($ele.data('id') != id) isSelf = false;
- if($target === null || ($target.data('id') !== id && (!isSelf))) isNew = true;
- $target = $newTarget;
- if(flex) {
- $targets.removeClass('drop-to');
- }
- $target.addClass('drop-to');
- }
-
-
- if(!flex) {
- $ele.toggleClass('drop-in', isIn);
- $shadow.toggleClass('drop-in', isIn);
- } else if($target !== null && $target.length) {
- isIn = true;
- }
-
- if(!canMoveHere || canMoveHere($ele, $target) !== false) {
- that.trigger('drag', {
- event: event,
- isIn: isIn,
- target: $target,
- element: $ele,
- isNew: isNew,
- selfTarget: isSelf,
- clickOffset: clickOffset,
- offset: offset,
- position: {
- left: offset.left - containerOffset.left,
- top: offset.top - containerOffset.top
- },
- mouseOffset: mouseOffset
- });
- }
-
- event.preventDefault();
- };
-
- var mouseUp = function(event) {
- $(document).off(eventSuffix);
- clearTimeout(mouseDownBackEventCall);
- if(!isMouseDown) return;
-
- isMouseDown = false;
-
- if(oldCssPosition) {
- $container.css('position', oldCssPosition);
- }
-
- if($shadow === null) {
- $ele.removeClass('drag-from');
- that.trigger('always', {
- event: event,
- cancel: true
- });
- return;
- }
-
- if(!isIn) $target = null;
- var isSure = true;
- mouseOffset = event ? {
- left: event.pageX,
- top: event.pageY
- } : lastMouseOffset;
- var offset = {
- left: mouseOffset.left - clickOffset.left,
- top: mouseOffset.top - clickOffset.top
- };
- var moveOffset = {
- left: mouseOffset.left - lastMouseOffset.left,
- top: mouseOffset.top - lastMouseOffset.top
- };
- lastMouseOffset.left = mouseOffset.left;
- lastMouseOffset.top = mouseOffset.top;
- var eventOptions = {
- event: event,
- isIn: isIn,
- target: $target,
- element: $ele,
- isNew: (!isSelf) && $target !== null,
- selfTarget: isSelf,
- offset: offset,
- mouseOffset: mouseOffset,
- position: {
- left: offset.left - containerOffset.left,
- top: offset.top - containerOffset.top
- },
- lastMouseOffset: lastMouseOffset,
- moveOffset: moveOffset
- };
-
- isSure = that.trigger('beforeDrop', eventOptions);
-
- if(isSure && isIn) {
- that.trigger('drop', eventOptions);
- }
-
- $targets.removeClass('drop-to');
- $ele.removeClass('dragging').removeClass('drag-from');
- $shadow.remove();
- $shadow = null;
-
- that.trigger('finish', eventOptions);
- that.trigger('always', eventOptions);
-
- if(event) event.preventDefault();
- };
-
- var mouseDown = function(event) {
- var mouseButton = $.zui.getMouseButtonCode(setting.mouseButton);
- if(mouseButton > -1 && event.button !== mouseButton) {
- return;
- }
-
- var $mouseDownEle = $(this);
- if(selector) {
- $ele = handle ? $mouseDownEle.closest(selector) : $mouseDownEle;
- }
-
- if($ele.hasClass('drag-shadow')) {
- return;
- }
-
- if(setting['before']) {
- if(setting['before']({
- event: event,
- element: $ele
- }) === false) return;
- }
-
- isMouseDown = true;
- $targets = $.isFunction(setting.target) ? setting.target($root) : $container.find(setting.target),
- $target = null,
- $shadow = null,
- isIn = false,
- isSelf = true,
- oldCssPosition = null,
- startOffset = $ele.offset(),
- containerOffset = $container.offset();
- startMouseOffset = {left: event.pageX, top: event.pageY};
- lastMouseOffset = $.extend({}, startMouseOffset);
- clickOffset = {
- left: startMouseOffset.left - startOffset.left,
- top: startMouseOffset.top - startOffset.top
- };
-
- $ele.addClass('drag-from');
- $(document).on(mouseMoveEvent, mouseMove).on(mouseUpEvent, mouseUp);
- mouseDownBackEventCall = setTimeout(function() {
- $(document).on(mouseDownEvent, mouseUp);
- }, 10);
- event.preventDefault();
- };
-
- if(handle) {
- $root.on(mouseDownEvent, handle, mouseDown);
- } else if(selector) {
- $root.on(mouseDownEvent, selector, mouseDown);
- } else {
- $root.on(mouseDownEvent, mouseDown);
- }
- };
-
- Droppable.prototype.destroy = function() {
- var eventSuffix = '.' + NAME + '.' + this.id;
- this.$.off(eventSuffix);
- $(document).off(eventSuffix);
- this.$.data(NAME, null);
- };
-
- Droppable.prototype.reset = function() {
- this.destroy();
- this.init();
- };
-
- $.fn.droppable = function(option) {
- return this.each(function() {
- var $this = $(this);
- var data = $this.data(NAME);
- var options = typeof option == 'object' && option;
-
- if(!data) $this.data(NAME, (data = new Droppable(this, options)));
-
- if(typeof option == 'string') data[option]();
- });
- };
-
- $.fn.droppable.Constructor = Droppable;
-}(jQuery, document, Math));
-
-/* ========================================================================
- * Bootstrap: modal.js v3.2.0
- * http://getbootstrap.com/javascript/#modals
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2011-2014 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * ========================================================================
- * Updates in ZUI:
- * 1. changed event namespace to *.zui.modal
- * 2. added position option to ajust poisition of modal
- * 3. added event 'escaping.zui.modal' with an param 'esc' to judge the esc
- * key down
- * 4. get moveable options value from '.modal-moveable' on '.modal-dialog'
- * 5. add setMoveable method to make modal dialog moveable
- * ======================================================================== */
-
-+ function($, undefined) {
- 'use strict';
-
- // MODAL CLASS DEFINITION
- // ======================
-
- var zuiname = 'zui.modal'
- var Modal = function(element, options) {
- var that = this;
- that.options = options
- that.$body = $(document.body)
- that.$element = $(element)
- that.$backdrop =
- that.isShown = null
- that.scrollbarWidth = 0
-
- if(options.moveable === undefined) {
- that.options.moveable = that.$element.hasClass('modal-moveable');
- }
-
- if(options.remote) {
- that.$element
- .find('.modal-content')
- .load(options.remote, function() {
- that.$element.trigger('loaded.' + zuiname)
- })
- }
- }
-
- Modal.VERSION = '3.2.0'
-
- Modal.TRANSITION_DURATION = 300
- Modal.BACKDROP_TRANSITION_DURATION = 150
-
- Modal.DEFAULTS = {
- backdrop: true,
- keyboard: true,
- show: true,
- // rememberPos: false,
- // moveable: false,
- position: 'fit' // 'center' or '40px' or '10%',
- };
-
- var setDialogPos = function($dialog, pos) {
- var $window = $(window);
- pos.left = Math.max(0, Math.min(pos.left, $window.width() - $dialog.outerWidth()));
- pos.top = Math.max(0, Math.min(pos.top, $window.height() - $dialog.outerHeight()));
- $dialog.css(pos);
- };
-
- Modal.prototype.toggle = function(_relatedTarget, position) {
- return this.isShown ? this.hide() : this.show(_relatedTarget, position)
- }
-
- Modal.prototype.ajustPosition = function(position) {
- var that = this;
- var options = that.options;
- if(position === undefined) position = options.position;
- if(position === undefined) return;
- if ($.isFunction(position)) {
- position = position(that);
- }
- var $dialog = that.$element.find('.modal-dialog');
-
- var half = Math.max(0, ($(window).height() - $dialog.outerHeight()) / 2);
- if (position === 'fit') {
- position = {marginTop: half * 2 / 3};
- } else if (position === 'center') {
- position = {marginTop: half};
- } else if (!$.isPlainObject(position)) {
- position = {marginTop: position};
- }
- if($dialog.hasClass('modal-moveable')) {
- var pos = null;
- var rememberPos = options.rememberPos;
- if(rememberPos) {
- if(rememberPos === true) {
- pos = that.$element.data('modal-pos');
- } else if($.zui.store) {
- pos = $.zui.store.pageGet(zuiname + '.rememberPos.' + rememberPos);
- }
- }
- position = $.extend(position, {left: Math.max(0, ($(window).width() - $dialog.outerWidth()) / 2)}, pos);
- if (options.moveable === 'inside') {
- setDialogPos($dialog, position);
- } else {
- $dialog.css(position);
- }
- } else {
- $dialog.css(position);
- }
- }
-
- Modal.prototype.setMoveale = function() {
- if(!$.fn.draggable) console.error('Moveable modal requires draggable.js.');
- var that = this;
- var options = that.options;
- var $dialog = that.$element.find('.modal-dialog').removeClass('modal-dragged');
- $dialog.toggleClass('modal-moveable', !!options.moveable);
-
- if(!that.$element.data('modal-moveable-setup')) {
- $dialog.draggable({
- container: that.$element,
- handle: '.modal-header',
- before: function() {
- var marginTop = $dialog.css('margin-top');
- if (marginTop && marginTop !== '0px') {
- $dialog.css('top', marginTop).css('margin-top', '').addClass('modal-dragged');
- }
- },
- finish: function(e) {
- var rememberPos = options.rememberPos;
- if(rememberPos) {
- that.$element.data('modal-pos', e.pos);
- if($.zui.store && rememberPos !== true) {
- $.zui.store.pageSet(zuiname + '.rememberPos.' + rememberPos, e.pos);
- }
- }
- },
- move: options.moveable === 'inside' ? function (dragPos) {
- setDialogPos($dialog, dragPos);
- } : true
- });
- }
- }
-
- Modal.prototype.show = function(_relatedTarget, position) {
- var that = this
- var e = $.Event('show.' + zuiname, {
- relatedTarget: _relatedTarget
- })
-
- that.$element.trigger(e)
-
- if(that.isShown || e.isDefaultPrevented()) return
-
- that.isShown = true
-
- if(that.options.moveable) that.setMoveale();
-
- that.checkScrollbar()
- if (that.options.backdrop !== false) {
- that.$body.addClass('modal-open')
- that.setScrollbar()
- }
-
- that.escape()
-
- that.$element.on('click.dismiss.' + zuiname, '[data-dismiss="modal"]', $.proxy(that.hide, that))
-
- that.backdrop(function() {
- var transition = $.support.transition && that.$element.hasClass('fade')
-
- if(!that.$element.parent().length) {
- that.$element.appendTo(that.$body) // don't move modals dom position
- }
-
- that.$element
- .show()
- .scrollTop(0)
-
- if(transition) {
- that.$element[0].offsetWidth // force reflow
- }
-
- that.$element
- .addClass('in')
- .attr('aria-hidden', false)
-
- that.ajustPosition(position);
-
- that.enforceFocus()
-
- var e = $.Event('shown.' + zuiname, {
- relatedTarget: _relatedTarget
- })
-
- transition ?
- that.$element.find('.modal-dialog') // wait for modal to slide in
- .one('bsTransitionEnd', function() {
- that.$element.trigger('focus').trigger(e)
- })
- .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
- that.$element.trigger('focus').trigger(e)
- })
- }
-
- Modal.prototype.hide = function(e) {
- if(e) e.preventDefault()
-
- var that = this;
-
- e = $.Event('hide.' + zuiname)
-
- that.$element.trigger(e)
-
- if(!that.isShown || e.isDefaultPrevented()) return
-
- that.isShown = false
-
- if (that.options.backdrop !== false) {
- that.$body.removeClass('modal-open')
- that.resetScrollbar()
- }
-
- that.escape()
-
- $(document).off('focusin.' + zuiname)
-
- that.$element
- .removeClass('in')
- .attr('aria-hidden', true)
- .off('click.dismiss.' + zuiname)
-
- $.support.transition && that.$element.hasClass('fade') ?
- that.$element
- .one('bsTransitionEnd', $.proxy(that.hideModal, that))
- .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
- that.hideModal()
- }
-
- Modal.prototype.enforceFocus = function() {
- $(document)
- .off('focusin.' + zuiname) // guard against infinite focus loop
- .on('focusin.' + zuiname, $.proxy(function(e) {
- if(this.$element[0] !== e.target && !this.$element.has(e.target).length) {
- this.$element.trigger('focus')
- }
- }, this))
- }
-
- Modal.prototype.escape = function() {
- if(this.isShown && this.options.keyboard) {
- $(document).on('keydown.dismiss.' + zuiname, $.proxy(function(e) {
- if(e.which == 27) {
- var et = $.Event('escaping.' + zuiname)
- var result = this.$element.triggerHandler(et, 'esc')
- if(result != undefined && (!result)) return
- this.hide()
- }
- }, this))
- } else if(!this.isShown) {
- $(document).off('keydown.dismiss.' + zuiname)
- }
- }
-
- Modal.prototype.hideModal = function() {
- var that = this
- this.$element.hide()
- this.backdrop(function() {
- that.$element.trigger('hidden.' + zuiname)
- })
- }
-
- Modal.prototype.removeBackdrop = function() {
- this.$backdrop && this.$backdrop.remove()
- this.$backdrop = null
- }
-
- Modal.prototype.backdrop = function(callback) {
- var that = this
- var animate = this.$element.hasClass('fade') ? 'fade' : ''
-
- if(this.isShown && this.options.backdrop) {
- var doAnimate = $.support.transition && animate
-
- this.$backdrop = $('')
- .appendTo(this.$body)
-
- this.$element.on('mousedown.dismiss.' + zuiname, $.proxy(function(e) {
- if(e.target !== e.currentTarget) return
- this.options.backdrop == 'static' ? this.$element[0].focus.call(this.$element[0]) : this.hide.call(this)
- }, this))
-
- if(doAnimate) this.$backdrop[0].offsetWidth // force reflow
-
- this.$backdrop.addClass('in')
-
- if(!callback) return
-
- doAnimate ?
- this.$backdrop
- .one('bsTransitionEnd', callback)
- .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
- callback()
-
- } else if(!this.isShown && this.$backdrop) {
- this.$backdrop.removeClass('in')
-
- var callbackRemove = function() {
- that.removeBackdrop()
- callback && callback()
- }
- $.support.transition && this.$element.hasClass('fade') ?
- this.$backdrop
- .one('bsTransitionEnd', callbackRemove)
- .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
- callbackRemove()
-
- } else if(callback) {
- callback()
- }
- }
-
- Modal.prototype.checkScrollbar = function() {
- if(document.body.clientWidth >= window.innerWidth) return
- this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
- }
-
- Modal.prototype.setScrollbar = function() {
- var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
- if(this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
- }
-
- Modal.prototype.resetScrollbar = function() {
- this.$body.css('padding-right', '')
- }
-
- Modal.prototype.measureScrollbar = function() { // thx walsh
- var scrollDiv = document.createElement('div')
- scrollDiv.className = 'modal-scrollbar-measure'
- this.$body.append(scrollDiv)
- var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
- this.$body[0].removeChild(scrollDiv)
- return scrollbarWidth
- }
-
-
- // MODAL PLUGIN DEFINITION
- // =======================
-
- function Plugin(option, _relatedTarget, position) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data(zuiname)
- var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
-
- if(!data) $this.data(zuiname, (data = new Modal(this, options)))
- if(typeof option == 'string') data[option](_relatedTarget, position)
- else if(options.show) data.show(_relatedTarget, position)
- })
- }
-
- var old = $.fn.modal
-
- $.fn.modal = Plugin
- $.fn.modal.Constructor = Modal
-
-
- // MODAL NO CONFLICT
- // =================
-
- $.fn.modal.noConflict = function() {
- $.fn.modal = old
- return this
- }
-
-
- // MODAL DATA-API
- // ==============
-
- $(document).on('click.' + zuiname + '.data-api', '[data-toggle="modal"]', function(e) {
- var $this = $(this)
- var href = $this.attr('href')
- var $target = null
- try {
- // strip for ie7
- $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
- } catch(ex) {
- return
- }
- if(!$target.length) return;
- var option = $target.data(zuiname) ? 'toggle' : $.extend({
- remote: !/#/.test(href) && href
- }, $target.data(), $this.data())
-
- if($this.is('a')) e.preventDefault()
-
- $target.one('show.' + zuiname, function(showEvent) {
- // only register focus restorer if modal will actually get shown
- if(showEvent.isDefaultPrevented()) return
- $target.one('hidden.' + zuiname, function() {
- $this.is(':visible') && $this.trigger('focus')
- })
- })
- Plugin.call($target, option, this, $this.data('position'))
- })
-
-}(jQuery, undefined);
-
-
-/* ========================================================================
- * ZUI: modal.trigger.js [1.2.0+]
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, window, undefined) {
- 'use strict';
-
- if(!$.fn.modal) throw new Error('Modal trigger requires modal.js');
-
- var NAME = 'zui.modaltrigger',
- STR_AJAX = 'ajax',
- ZUI_MODAL = '.zui.modal',
- STR_STRING = 'string';
-
- // MODAL TRIGGER CLASS DEFINITION
- // ======================
- var ModalTrigger = function(options, $trigger) {
- options = $.extend({}, ModalTrigger.DEFAULTS, $.ModalTriggerDefaults, $trigger ? $trigger.data() : null, options);
- this.isShown;
- this.$trigger = $trigger;
- this.options = options;
- this.id = $.zui.uuid();
- };
-
- ModalTrigger.DEFAULTS = {
- type: 'custom',
- // width: null, // number, css definition
- // size: null, // 'md', 'sm', 'lg', 'fullscreen'
- height: 'auto',
- // icon: null,
- name: 'triggerModal',
- // className: '',
- fade: true,
- position: 'fit',
- showHeader: true,
- delay: 0,
- // iframeBodyClass: '',
- // onlyIncreaseHeight: false,
- // moveable: false,
- // rememberPos: false,
- backdrop: true,
- keyboard: true,
- waittime: 0,
- loadingIcon: 'icon-spinner-indicator'
- };
-
- ModalTrigger.prototype.init = function(options) {
- var that = this;
- if(options.url) {
- if(!options.type || (options.type != STR_AJAX && options.type != 'iframe')) {
- options.type = STR_AJAX;
- }
- }
- if(options.remote) {
- options.type = STR_AJAX;
- if(typeof options.remote === STR_STRING) options.url = options.remote;
- } else if(options.iframe) {
- options.type = 'iframe';
- if(typeof options.iframe === STR_STRING) options.url = options.iframe;
- } else if(options.custom) {
- options.type = 'custom';
- if(typeof options.custom === STR_STRING) {
- var $doms;
- try {
- $doms = $(options.custom);
- } catch(e) {}
-
- if($doms && $doms.length) {
- options.custom = $doms;
- } else if($.isFunction(window[options.custom])) {
- options.custom = window[options.custom];
- }
- }
- }
-
- var $modal = $('#' + options.name);
- if($modal.length) {
- if(!that.isShown) $modal.off(ZUI_MODAL);
- $modal.remove();
- }
- $modal = $('' + (typeof options.loadingIcon === 'string' && options.loadingIcon.indexOf('icon-') === 0 ? (' ') : options.loadingIcon) + ' ').appendTo('body').data(NAME, that);
-
- var bindEvent = function(optonName, eventName) {
- var handleFunc = options[optonName];
- if($.isFunction(handleFunc)) $modal.on(eventName + ZUI_MODAL, handleFunc);
- };
- bindEvent('onShow', 'show');
- bindEvent('shown', 'shown');
- bindEvent('onHide', 'hide');
- bindEvent('hidden', 'hidden');
- bindEvent('loaded', 'loaded');
-
- $modal.on('shown' + ZUI_MODAL, function() {
- that.isShown = true;
- }).on('hidden' + ZUI_MODAL, function() {
- that.isShown = false;
- });
-
- this.$modal = $modal;
- this.$dialog = $modal.find('.modal-dialog');
-
- if(options.mergeOptions) this.options = options;
- };
-
- ModalTrigger.prototype.show = function(option) {
- var options = $.extend({}, this.options, {url: this.$trigger ? (this.$trigger.attr('href') || this.$trigger.attr('data-url') || this.$trigger.data('url')) : this.options.url}, option);
- this.init(options);
- var that = this,
- $modal = this.$modal,
- $dialog = this.$dialog,
- custom = options.custom;
- var $body = $dialog.find('.modal-body').css('padding', ''),
- $header = $dialog.find('.modal-header'),
- $content = $dialog.find('.modal-content');
-
- $modal.toggleClass('fade', options.fade)
- .addClass(options.className)
- .toggleClass('modal-loading', !this.isShown);
-
- $dialog.toggleClass('modal-md', options.size === 'md')
- .toggleClass('modal-sm', options.size === 'sm')
- .toggleClass('modal-lg', options.size === 'lg')
- .toggleClass('modal-fullscreen', options.size === 'fullscreen');
-
- $header.toggle(options.showHeader);
- $header.find('.modal-icon').attr('class', 'modal-icon icon-' + options.icon);
- $header.find('.modal-title-name').text(options.title || '');
- if(options.size && options.size === 'fullscreen') {
- options.width = '';
- options.height = '';
- }
-
- var resizeDialog = function() {
- clearTimeout(this.resizeTask);
- this.resizeTask = setTimeout(function() {
- that.ajustPosition(options.position);
- }, 100);
- };
-
- var readyToShow = function(delay, callback) {
- if(typeof delay === 'undefined') delay = options.delay;
- return setTimeout(function() {
- $dialog = $modal.find('.modal-dialog');
- if(options.width && options.width != 'auto') {
- $dialog.css('width', options.width);
- }
- if(options.height && options.height != 'auto') {
- $dialog.css('height', options.height);
- if(options.type === 'iframe') $body.css('height', $dialog.height() - $header.outerHeight());
- }
- that.ajustPosition(options.position);
- $modal.removeClass('modal-loading');
-
- if(options.type != 'iframe') {
- $dialog.off('resize.' + NAME).on('resize.' + NAME, resizeDialog);
- }
-
- callback && callback();
- }, delay);
- };
-
- if(options.type === 'custom' && custom) {
- if($.isFunction(custom)) {
- var customContent = custom({
- modal: $modal,
- options: options,
- modalTrigger: that,
- ready: readyToShow
- });
- if(typeof customContent === STR_STRING) {
- $body.html(customContent);
- readyToShow();
- }
- } else if(custom instanceof $) {
- $body.html($('').append(custom.clone()).html());
- readyToShow();
- } else {
- $body.html(custom);
- readyToShow();
- }
- } else if(options.url) {
- var onLoadBroken = function() {
- var brokenContent = $modal.callComEvent(that, 'broken');
- if(brokenContent) {
- $body.html(brokenContent);
- readyToShow();
- }
- };
-
- $modal.attr('ref', options.url);
- if(options.type === 'iframe') {
- $modal.addClass('modal-iframe');
- this.firstLoad = true;
- var iframeName = 'iframe-' + options.name;
- $header.detach();
- $body.detach();
- $content.empty().append($header).append($body);
- $body.css('padding', 0)
- .html(' ');
-
- if(options.waittime > 0) {
- that.waitTimeout = readyToShow(options.waittime, onLoadBroken);
- }
-
- var frame = document.getElementById(iframeName);
- frame.onload = frame.onreadystatechange = function() {
- if(that.firstLoad) $modal.addClass('modal-loading');
- if(this.readyState && this.readyState != 'complete') return;
- that.firstLoad = false;
-
- if(options.waittime > 0) {
- clearTimeout(that.waitTimeout);
- }
-
- try {
- $modal.attr('ref', frame.contentWindow.location.href);
- var frame$ = window.frames[iframeName].$;
- if(frame$ && options.height === 'auto' && options.size != 'fullscreen') {
- // todo: update iframe url to ref attribute
- var $framebody = frame$('body').addClass('body-modal');
- if(options.iframeBodyClass) $framebody.addClass(options.iframeBodyClass);
- var ajustFrameSize = function(check) {
- $modal.removeClass('fade');
- var height = $framebody.outerHeight();
- if(check === true && options.onlyIncreaseHeight) {
- height = Math.max(height, $body.data('minModalHeight') || 0);
- $body.data('minModalHeight', height);
- }
- $body.css('height', height);
- if(options.fade) $modal.addClass('fade');
- readyToShow();
- };
-
- $modal.callComEvent(that, 'loaded', {
- modalType: 'iframe',
- jQuery: frame$
- });
-
- setTimeout(ajustFrameSize, 100);
-
- $framebody.off('resize.' + NAME).on('resize.' + NAME, resizeDialog);
- } else {
- readyToShow();
- }
-
- frame$.extend({
- closeModal: window.closeModal
- });
- } catch(e) {
- readyToShow();
- }
- };
- } else {
- $.ajax($.extend({
- url: options.url,
- success: function(data) {
- try {
- var $data = $(data);
- if($data.filter('.modal-dialog').length) {
- $dialog.replaceWith($data);
- } else if($data.filter('.modal-content').length) {
- $dialog.find('.modal-content').replaceWith($data);
- } else {
- $body.wrapInner($data);
- }
- } catch(e) {
- if (window.console && window.console.warn) {
- console.warn('ZUI: Cannot recogernize remote content.', {error: e, data: data});
- }
- $modal.html(data);
- }
- $modal.callComEvent(that, 'loaded', {
- modalType: STR_AJAX
- });
- readyToShow();
- },
- error: onLoadBroken
- }, options.ajaxOptions));
- }
- }
-
- $modal.modal({
- show : 'show',
- backdrop : options.backdrop,
- moveable : options.moveable,
- rememberPos: options.rememberPos,
- keyboard : options.keyboard
- });
- };
-
- ModalTrigger.prototype.close = function(callback, redirect) {
- if(callback || redirect) {
- this.$modal.on('hidden' + ZUI_MODAL, function() {
- if($.isFunction(callback)) callback();
-
- if(typeof redirect === STR_STRING) {
- if(redirect === 'this') window.location.reload();
- else window.location = redirect;
- }
- });
- }
- this.$modal.modal('hide');
- };
-
- ModalTrigger.prototype.toggle = function(options) {
- if(this.isShown) this.close();
- else this.show(options);
- };
-
- ModalTrigger.prototype.ajustPosition = function(position) {
- position = position === undefined ? this.options.position : position;
- if ($.isFunction(position)) {
- position = position(this);
- }
- this.$modal.modal('ajustPosition', position);
- };
-
- $.zui({
- ModalTrigger: ModalTrigger,
- modalTrigger: new ModalTrigger()
- });
-
- $.fn.modalTrigger = function(option, settings) {
- return $(this).each(function() {
- var $this = $(this);
- var data = $this.data(NAME),
- options = $.extend({
- title: $this.attr('title') || $this.text(),
- url: $this.attr('href'),
- type: $this.hasClass('iframe') ? 'iframe' : ''
- }, $this.data(), $.isPlainObject(option) && option);
- if(!data) $this.data(NAME, (data = new ModalTrigger(options, $this)));
- if(typeof option == STR_STRING) data[option](settings);
- else if(options.show) data.show(settings);
-
- $this.on((options.trigger || 'click') + '.toggle.' + NAME, function(e) {
- data.toggle(options);
- if($this.is('a')) e.preventDefault();
- });
- });
- };
-
- var old = $.fn.modal;
- $.fn.modal = function(option, settings) {
- return $(this).each(function() {
- var $this = $(this);
- if($this.hasClass('modal')) old.call($this, option, settings);
- else $this.modalTrigger(option, settings);
- });
- };
-
- var getModal = function(modal) {
- var modalType = typeof(modal);
- if(modalType === 'undefined') {
- modal = $('.modal.modal-trigger');
- } else if(modalType === STR_STRING) {
- modal = $(modal);
- }
- if(modal && (modal instanceof $)) return modal;
- return null;
- };
-
- // callback, redirect, modal
- var closeModal = function(modal, callback, redirect) {
- if($.isFunction(modal)) {
- var oldModal = redirect;
- redirect = callback;
- callback = modal;
- modal = oldModal;
- }
- modal = getModal(modal);
- if(modal && modal.length) {
- modal.each(function() {
- $(this).data(NAME).close(callback, redirect);
- });
- }
- };
-
- var ajustModalPosition = function(position, modal) {
- modal = getModal(modal);
- if(modal && modal.length) {
- modal.modal('ajustPosition', position);
- }
- };
-
- $.zui({
- closeModal: closeModal,
- ajustModalPosition: ajustModalPosition
- });
-
- $(document).on('click.' + NAME + '.data-api', '[data-toggle="modal"]', function(e) {
- var $this = $(this);
- var href = $this.attr('href');
- var $target = null;
- try {
- $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
- } catch(ex) {}
- if(!$target || !$target.length) {
- if(!$this.data(NAME)) {
- $this.modalTrigger({
- show: true,
- });
- } else {
- $this.trigger('.toggle.' + NAME);
- }
- }
- if($this.is('a')) {
- e.preventDefault();
- }
- });
-}(window.jQuery, window, undefined));
-
-
-/* ========================================================================
- * Bootstrap: tooltip.js v3.0.0
- * http://twzui.github.com/bootstrap/javascript.html#tooltip
- * Inspired by the original jQuery.tipsy by Jason Frame
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // TOOLTIP PUBLIC CLASS DEFINITION
- // ===============================
-
- var Tooltip = function(element, options) {
- this.type = null
- this.options = null
- this.enabled = null
- this.timeout = null
- this.hoverState = null
- this.$element = null
-
- this.init('tooltip', element, options)
- }
-
- Tooltip.DEFAULTS = {
- animation: true,
- placement: 'top',
- selector: false,
- template: ' ',
- trigger: 'hover focus',
- title: '',
- delay: 0,
- html: false,
- container: false
- }
-
- Tooltip.prototype.init = function(type, element, options) {
- this.enabled = true
- this.type = type
- this.$element = $(element)
- this.options = this.getOptions(options)
-
- var triggers = this.options.trigger.split(' ')
-
- for(var i = triggers.length; i--;) {
- var trigger = triggers[i]
-
- if(trigger == 'click') {
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
- } else if(trigger != 'manual') {
- var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
- var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
-
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
- }
- }
-
- this.options.selector ?
- (this._options = $.extend({}, this.options, {
- trigger: 'manual',
- selector: ''
- })) :
- this.fixTitle()
- }
-
- Tooltip.prototype.getDefaults = function() {
- return Tooltip.DEFAULTS
- }
-
- Tooltip.prototype.getOptions = function(options) {
- options = $.extend({}, this.getDefaults(), this.$element.data(), options)
-
- if(options.delay && typeof options.delay == 'number') {
- options.delay = {
- show: options.delay,
- hide: options.delay
- }
- }
-
- return options
- }
-
- Tooltip.prototype.getDelegateOptions = function() {
- var options = {}
- var defaults = this.getDefaults()
-
- this._options && $.each(this._options, function(key, value) {
- if(defaults[key] != value) options[key] = value
- })
-
- return options
- }
-
- Tooltip.prototype.enter = function(obj) {
- var self = obj instanceof this.constructor ?
- obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('zui.' + this.type)
-
- clearTimeout(self.timeout)
-
- self.hoverState = 'in'
-
- if(!self.options.delay || !self.options.delay.show) return self.show()
-
- self.timeout = setTimeout(function() {
- if(self.hoverState == 'in') self.show()
- }, self.options.delay.show)
- }
-
- Tooltip.prototype.leave = function(obj) {
- var self = obj instanceof this.constructor ?
- obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('zui.' + this.type)
-
- clearTimeout(self.timeout)
-
- self.hoverState = 'out'
-
- if(!self.options.delay || !self.options.delay.hide) return self.hide()
-
- self.timeout = setTimeout(function() {
- if(self.hoverState == 'out') self.hide()
- }, self.options.delay.hide)
- }
-
- Tooltip.prototype.show = function(content) {
- var e = $.Event('show.zui.' + this.type)
-
- if((content || this.hasContent()) && this.enabled) {
- var that = this
- that.$element.trigger(e)
-
- if(e.isDefaultPrevented()) return
-
- var $tip = that.tip()
-
- that.setContent(content)
-
- if(that.options.animation) $tip.addClass('fade')
-
- var placement = typeof that.options.placement == 'function' ?
- that.options.placement.call(that, $tip[0], that.$element[0]) :
- that.options.placement
-
- var autoToken = /\s?auto?\s?/i
- var autoPlace = autoToken.test(placement)
- if(autoPlace) placement = placement.replace(autoToken, '') || 'top'
-
- $tip
- .detach()
- .css({
- top: 0,
- left: 0,
- display: 'block'
- })
- .addClass(placement)
-
- that.options.container ? $tip.appendTo(that.options.container) : $tip.insertAfter(that.$element)
-
- var pos = that.getPosition()
- var actualWidth = $tip[0].offsetWidth
- var actualHeight = $tip[0].offsetHeight
-
- if(autoPlace) {
- var $parent = that.$element.parent()
-
- var orgPlacement = placement
- var docScroll = document.documentElement.scrollTop || document.body.scrollTop
- var parentWidth = that.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
- var parentHeight = that.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
- var parentLeft = that.options.container == 'body' ? 0 : $parent.offset().left
-
- placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
- placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
- placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
- placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
- placement
-
- $tip
- .removeClass(orgPlacement)
- .addClass(placement)
- }
-
- var calculatedOffset = that.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
-
- that.applyPlacement(calculatedOffset, placement)
- var complete = function () {
- var prevHoverState = that.hoverState
- that.$element.trigger('shown.zui.' + that.type)
- that.hoverState = null
-
- if (prevHoverState == 'out') that.leave(that)
- }
-
- $.support.transition && that.$tip.hasClass('fade') ?
- $tip
- .one('bsTransitionEnd', complete)
- .emulateTransitionEnd(150) :
- complete()
- }
- }
-
- Tooltip.prototype.applyPlacement = function(offset, placement) {
- var replace
- var $tip = this.tip()
- var width = $tip[0].offsetWidth
- var height = $tip[0].offsetHeight
-
- // manually read margins because getBoundingClientRect includes difference
- var marginTop = parseInt($tip.css('margin-top'), 10)
- var marginLeft = parseInt($tip.css('margin-left'), 10)
-
- // we must check for NaN for ie 8/9
- if(isNaN(marginTop)) marginTop = 0
- if(isNaN(marginLeft)) marginLeft = 0
-
- offset.top = offset.top + marginTop
- offset.left = offset.left + marginLeft
-
- $tip
- .offset(offset)
- .addClass('in')
-
- // check to see if placing tip in new offset caused the tip to resize itself
- var actualWidth = $tip[0].offsetWidth
- var actualHeight = $tip[0].offsetHeight
-
- if(placement == 'top' && actualHeight != height) {
- replace = true
- offset.top = offset.top + height - actualHeight
- }
-
- if(/bottom|top/.test(placement)) {
- var delta = 0
-
- if(offset.left < 0) {
- delta = offset.left * -2
- offset.left = 0
-
- $tip.offset(offset)
-
- actualWidth = $tip[0].offsetWidth
- actualHeight = $tip[0].offsetHeight
- }
-
- this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
- } else {
- this.replaceArrow(actualHeight - height, actualHeight, 'top')
- }
-
- if(replace) $tip.offset(offset)
- }
-
- Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
- this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
- }
-
- Tooltip.prototype.setContent = function(content) {
- var $tip = this.tip()
- var title = content || this.getTitle()
-
- if(this.options.tipId) $tip.attr('id', this.options.tipId)
- if(this.options.tipClass) $tip.addClass(this.options.tipClass)
-
- $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
- $tip.removeClass('fade in top bottom left right')
- }
-
- Tooltip.prototype.hide = function() {
- var that = this
- var $tip = this.tip()
- var e = $.Event('hide.zui.' + this.type)
-
- function complete() {
- if(that.hoverState != 'in') $tip.detach()
- }
-
- this.$element.trigger(e)
-
- if(e.isDefaultPrevented()) return
-
- $tip.removeClass('in')
-
- $.support.transition && this.$tip.hasClass('fade') ?
- $tip
- .one($.support.transition.end, complete)
- .emulateTransitionEnd(150) :
- complete()
-
- this.$element.trigger('hidden.zui.' + this.type)
-
- return this
- }
-
- Tooltip.prototype.fixTitle = function() {
- var $e = this.$element
- if($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
- $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
- }
- }
-
- Tooltip.prototype.hasContent = function() {
- return this.getTitle()
- }
-
- Tooltip.prototype.getPosition = function() {
- var el = this.$element[0]
- return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
- width: el.offsetWidth,
- height: el.offsetHeight
- }, this.$element.offset())
- }
-
- Tooltip.prototype.getCalculatedOffset = function(placement, pos, actualWidth, actualHeight) {
- return placement == 'bottom' ? {
- top: pos.top + pos.height,
- left: pos.left + pos.width / 2 - actualWidth / 2
- } :
- placement == 'top' ? {
- top: pos.top - actualHeight,
- left: pos.left + pos.width / 2 - actualWidth / 2
- } :
- placement == 'left' ? {
- top: pos.top + pos.height / 2 - actualHeight / 2,
- left: pos.left - actualWidth
- } :
- /* placement == 'right' */
- {
- top: pos.top + pos.height / 2 - actualHeight / 2,
- left: pos.left + pos.width
- }
- }
-
- Tooltip.prototype.getTitle = function() {
- var title
- var $e = this.$element
- var o = this.options
-
- title = $e.attr('data-original-title') || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
-
- return title
- }
-
- Tooltip.prototype.tip = function() {
- return this.$tip = this.$tip || $(this.options.template)
- }
-
- Tooltip.prototype.arrow = function() {
- return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
- }
-
- Tooltip.prototype.validate = function() {
- if(!this.$element[0].parentNode) {
- this.hide()
- this.$element = null
- this.options = null
- }
- }
-
- Tooltip.prototype.enable = function() {
- this.enabled = true
- }
-
- Tooltip.prototype.disable = function() {
- this.enabled = false
- }
-
- Tooltip.prototype.toggleEnabled = function() {
- this.enabled = !this.enabled
- }
-
- Tooltip.prototype.toggle = function(e) {
- var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('zui.' + this.type) : this
- self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
- }
-
- Tooltip.prototype.destroy = function() {
- this.hide().$element.off('.' + this.type).removeData('zui.' + this.type)
- }
-
-
- // TOOLTIP PLUGIN DEFINITION
- // =========================
-
- var old = $.fn.tooltip
-
- $.fn.tooltip = function(option, params) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data('zui.tooltip')
- var options = typeof option == 'object' && option
-
- if(!data) $this.data('zui.tooltip', (data = new Tooltip(this, options)))
- if(typeof option == 'string') data[option](params)
- })
- }
-
- $.fn.tooltip.Constructor = Tooltip
-
-
- // TOOLTIP NO CONFLICT
- // ===================
-
- $.fn.tooltip.noConflict = function() {
- $.fn.tooltip = old
- return this
- }
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * Bootstrap: popover.js v3.0.0
- * http://twbs.github.com/bootstrap/javascript.html#popovers
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // POPOVER PUBLIC CLASS DEFINITION
- // ===============================
-
- var Popover = function(element, options) {
- this.init('popover', element, options)
- }
-
- if(!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
-
- Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
- placement: 'right',
- trigger: 'click',
- content: '',
- template: ' '
- })
-
-
- // NOTE: POPOVER EXTENDS tooltip.js
- // ================================
-
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
-
- Popover.prototype.constructor = Popover
-
- Popover.prototype.getDefaults = function() {
- return Popover.DEFAULTS
- }
-
- Popover.prototype.setContent = function() {
- var $tip = this.tip()
- var target = this.getTarget()
-
- if(target) {
- if(target.find('.arrow').length < 1)
- $tip.addClass('no-arrow')
- $tip.html(target.html())
- return
- }
-
- var title = this.getTitle()
- var content = this.getContent()
-
- $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
- $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
-
- $tip.removeClass('fade top bottom left right in')
-
- if(this.options.tipId) $tip.attr('id', this.options.tipId)
- if(this.options.tipClass) $tip.addClass(this.options.tipClass)
-
- // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
- // this manually by checking the contents.
- if(!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
- }
-
- Popover.prototype.hasContent = function() {
- return this.getTarget() || this.getTitle() || this.getContent()
- }
-
- Popover.prototype.getContent = function() {
- var $e = this.$element
- var o = this.options
-
- return $e.attr('data-content') || (typeof o.content == 'function' ?
- o.content.call($e[0]) :
- o.content)
- }
-
- Popover.prototype.getTarget = function() {
- var $e = this.$element
- var o = this.options
-
- var target = $e.attr('data-target') || (typeof o.target == 'function' ?
- o.target.call($e[0]) :
- o.target)
- return(target && true) ? (target == '$next' ? $e.next('.popover') : $(target)) : false
- }
-
- Popover.prototype.arrow = function() {
- return this.$arrow = this.$arrow || this.tip().find('.arrow')
- }
-
- Popover.prototype.tip = function() {
- if(!this.$tip) this.$tip = $(this.options.template)
- return this.$tip
- }
-
-
- // POPOVER PLUGIN DEFINITION
- // =========================
-
- var old = $.fn.popover
-
- $.fn.popover = function(option) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data('zui.popover')
- var options = typeof option == 'object' && option
-
- if(!data) $this.data('zui.popover', (data = new Popover(this, options)))
- if(typeof option == 'string') data[option]()
- })
- }
-
- $.fn.popover.Constructor = Popover
-
-
- // POPOVER NO CONFLICT
- // ===================
-
- $.fn.popover.noConflict = function() {
- $.fn.popover = old
- return this
- }
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * Bootstrap: dropdown.js v3.0.0
- * http://twbs.github.com/bootstrap/javascript.html#dropdowns
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * Bootsrap version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================================== */
-
-
-+ function($) {
- 'use strict';
-
- // DROPDOWN CLASS DEFINITION
- // =========================
-
- var zuiname = 'zui.dropdown';
- var backdrop = '.dropdown-backdrop'
- var toggle = '[data-toggle=dropdown]'
- var Dropdown = function(element) {
- var $el = $(element).on('click.' + zuiname, this.toggle)
- }
-
- Dropdown.prototype.toggle = function(e) {
- var $this = $(this)
-
- if($this.is('.disabled, :disabled')) return
-
- var $parent = getParent($this)
- var isActive = $parent.hasClass('open')
-
- clearMenus()
-
- if(!isActive) {
- if('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
- // if mobile we we use a backdrop because click events don't delegate
- $(' ').insertAfter($(this)).on('click', clearMenus)
- }
-
- $parent.trigger(e = $.Event('show.' + zuiname))
-
- if(e.isDefaultPrevented()) return
-
- $parent
- .toggleClass('open')
- .trigger('shown.' + zuiname)
-
- $this.focus()
- }
-
- return false
- }
-
- Dropdown.prototype.keydown = function(e) {
- if(!/(38|40|27)/.test(e.keyCode)) return
-
- var $this = $(this)
-
- e.preventDefault()
- e.stopPropagation()
-
- if($this.is('.disabled, :disabled')) return
-
- var $parent = getParent($this)
- var isActive = $parent.hasClass('open')
-
- if(!isActive || (isActive && e.keyCode == 27)) {
- if(e.which == 27) $parent.find(toggle).focus()
- return $this.click()
- }
-
- var $items = $('[role=menu] li:not(.divider):visible a', $parent)
-
- if(!$items.length) return
-
- var index = $items.index($items.filter(':focus'))
-
- if(e.keyCode == 38 && index > 0) index-- // up
- if(e.keyCode == 40 && index < $items.length - 1) index++ // down
- if(!~index) index = 0
-
- $items.eq(index).focus()
- }
-
- function clearMenus() {
- $(backdrop).remove()
- $(toggle).each(function(e) {
- var $parent = getParent($(this))
- if(!$parent.hasClass('open')) return
- $parent.trigger(e = $.Event('hide.' + zuiname))
- if(e.isDefaultPrevented()) return
- $parent.removeClass('open').trigger('hidden.' + zuiname)
- })
- }
-
- function getParent($this) {
- var selector = $this.attr('data-target')
-
- if(!selector) {
- selector = $this.attr('href')
- selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
- var $parent;
- try {
- $parent = selector && $(selector);
- } catch(e) {}
- return $parent && $parent.length ? $parent : $this.parent()
- }
-
-
- // DROPDOWN PLUGIN DEFINITION
- // ==========================
-
- var old = $.fn.dropdown
-
- $.fn.dropdown = function(option) {
- return this.each(function() {
- var $this = $(this)
- var data = $this.data('dropdown')
-
- if(!data) $this.data('dropdown', (data = new Dropdown(this)))
- if(typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.dropdown.Constructor = Dropdown
-
-
- // DROPDOWN NO CONFLICT
- // ====================
-
- $.fn.dropdown.noConflict = function() {
- $.fn.dropdown = old
- return this
- }
-
-
- // APPLY TO STANDARD DROPDOWN ELEMENTS
- // ===================================
-
- var apiName = zuiname + '.data-api'
- $(document)
- .on('click.' + apiName, clearMenus)
- .on('click.' + apiName, '.dropdown form', function(e) {
- e.stopPropagation()
- })
- .on('click.' + apiName, toggle, Dropdown.prototype.toggle)
- .on('keydown.' + apiName, toggle + ', [role=menu]', Dropdown.prototype.keydown)
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * ZUI: messager.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, window, undefined) {
- 'use strict';
-
- var id = 0;
- var template = ' ';
- var DEFAULTS = {
- type: 'default',
- placement: 'top',
- time: 4000,
- parent: 'body',
- // clear: false,
- icon: null,
- close: true,
- // actions: [{icon, name, action, title}],
- // contentClass: null,
- // cssClass: null,
- // onAction: function,
- fade: true,
- scale: true
- };
- var all = {};
-
- var Messager = function(message, options) {
- if($.isPlainObject(message)) {
- options = message;
- message = options.message;
- }
-
- var that = this;
- options = that.options = $.extend({}, DEFAULTS, options);
-
- that.id = options.id || (id++);
- var oldMessager = all[that.id];
- if(oldMessager) oldMessager.destroy();
- all[that.id] = that;
- that.message = (options.icon ? ' ' : '') + message;
-
- that.$ = $(template.format(options)).toggleClass('fade', options.fade).toggleClass('scale', options.scale).attr('id', 'messager-' + that.id);
-
- if(options.cssClass) that.$.addClass(options.cssClass);
-
- var hasCloseAction = false;
- var $actions = that.$.find('.messager-actions');
- var appendAction = function(action) {
- var $btn = $(' ');
- if(action.name === 'close') $btn.addClass('close');
- if(action.html !== undefined) {
- $btn.html(action.html);
- }
- if(action.icon !== undefined) {
- $btn.append(' ');
- }
- if(action.text !== undefined) {
- $btn.append(' ' + action.text + '');
- }
- if(action.tooltip !== undefined) {
- $btn.attr('title', action.tooltip).tooltip();
- }
- $btn.data('action', action);
- $actions.append($btn);
- };
- if(options.actions) {
- $.each(options.actions, function(idx, action) {
- if(action.name === undefined) action.name = idx;
- if(action.name == 'close') hasCloseAction = true;
- appendAction(action);
- });
- }
- if(!hasCloseAction && options.close) {
- appendAction({name: 'close', html: '×'});
- }
-
- that.$.on('click', '.action', function(e) {
- var action = $(this).data('action'), result;
- if(options.onAction) {
- result = options.onAction.call(this, action.name, action, that);
- if(result === false) return;
- }
- if($.isFunction(action.action)) {
- result = action.action.call(this, that);
- if(result === false) return;
- }
- that.hide();
- e.stopPropagation();
- });
-
- that.$.on('click', function(e) {
- if(options.onAction) {
- var result = options.onAction.call(this, 'content', null, that);
- if(result === true) that.hide();
- }
- });
-
- var $content = that.$.find('.messager-content').html(that.message);
- if(options.contentClass) $content.addClass(options.contentClass);
-
- that.$.data('zui.messager', that);
-
- if(options.show && that.message !== undefined) {
- that.show();
- }
- };
-
- Messager.prototype.update = function(message, newOptions) {
- var that = this;
- var options = that.options;
- that.$.removeClass('messager-' + options.type);
- if(newOptions) {
- options = $.extend(options, newOptions);
- }
- that.$.addClass('messager-' + options.type);
- if(message) {
- that.message = (options.icon ? ' ' : '') + message;
- that.$.find('.messager-content').html(that.message);
- }
- };
-
- Messager.prototype.show = function(message, callback) {
- var that = this,
- options = this.options;
-
- if($.isFunction(message)) {
- var oldCallback = callback;
- callback = message;
- if(oldCallback !== undefined) {
- message = oldCallback;
- }
- }
-
- if(that.isShow) {
- that.hide(function() {
- that.show(message, callback);
- });
- return;
- }
-
- if(that.hiding) {
- clearTimeout(that.hiding);
- that.hiding = null;
- }
-
- that.update(message);
-
- var placement = options.placement;
- var $parent = $(options.parent);
- var $holder = $parent.children('.messagers-holder.' + placement);
- if(!$holder.length) {
- $holder = $(' ').attr('class', 'messagers-holder ' + placement).appendTo($parent);
- }
- $holder.append(that.$);
- if(placement === 'center') {
- var offset = $(window).height() - $holder.height();
- $holder.css('top', Math.max(-offset, offset/2));
- }
-
- that.$.show().addClass('in');
-
- if(options.time) {
- that.hiding = setTimeout(function() {
- that.hide();
- }, options.time);
- }
-
- that.isShow = true;
- callback && callback();
- return that;
- };
-
- Messager.prototype.hide = function(callback, immediately) {
- if(callback === true) {
- immediately = true;
- callback = null;
- }
- var that = this;
- if(that.$.hasClass('in')) {
- that.$.removeClass('in');
- var removeMessager = function() {
- var $parent = that.$.parent();
- that.$.detach();
- if(!$parent.children().length) $parent.remove();
- callback && callback(true);
- };
- if(immediately) removeMessager();
- else setTimeout(removeMessager, 200);
- } else {
- callback && callback(false);
- }
-
- that.isShow = false;
- };
-
- Messager.prototype.destroy = function() {
- var that = this;
- that.hide(function()
- {
- that.$.remove();
- that.$ = null;
- }, true);
- delete all[that.id];
- };
-
- Messager.all = all;
- Messager.DEFAULTS = DEFAULTS;
-
- var hideMessage = function() {
- $('.messager').each(function() {
- var msg = $(this).data('zui.messager');
- if(msg && msg.hide) msg.hide(true);
- });
- };
-
- var showMessage = function(message, options) {
- if(typeof options === 'string') {
- options = {
- type: options
- };
- }
- options = $.extend({}, options);
- if(options.id === undefined) hideMessage();
- var msg = all[options.id] || new Messager(message, options);
- msg.show();
- return msg;
- };
-
- var getOptions = function(options) {
- return(typeof options === 'string') ? {
- placement: options
- } : options;
- };
-
- var zuiMessager = {
- show: showMessage,
- hide: hideMessage
- };
-
- $.each({
- primary : 0,
- success : 'ok-sign',
- info : 'info-sign',
- warning : 'warning-sign',
- danger : 'exclamation-sign',
- important: 0,
- special : 0
- }, function(name, icon){
- zuiMessager[name] = function(message, options) {
- return showMessage(message, $.extend({
- type: name,
- icon: icon || null
- }, getOptions(options)));
- };
- });
-
- $.zui({
- Messager: Messager,
- showMessager: showMessage,
- messager: zuiMessager
- });
-}(jQuery, window, undefined));
-
-
-/* ========================================================================
- * ZUI: color.js
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2014-2016 cnezsoft.com; Licensed MIT
- * ======================================================================== */
-
-
-(function($, Math, window, undefined) {
- 'use strict';
-
- var hexReg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,
- N255 = 255,
- N360 = 360,
- N100 = 100,
- STR_STRING = 'string',
- STR_OBJECT = 'object',
- namedColors = {
- aliceblue: '#f0f8ff',
- antiquewhite: '#faebd7',
- aqua: '#00ffff',
- aquamarine: '#7fffd4',
- azure: '#f0ffff',
- beige: '#f5f5dc',
- bisque: '#ffe4c4',
- black: '#000000',
- blanchedalmond: '#ffebcd',
- blue: '#0000ff',
- blueviolet: '#8a2be2',
- brown: '#a52a2a',
- burlywood: '#deb887',
- cadetblue: '#5f9ea0',
- chartreuse: '#7fff00',
- chocolate: '#d2691e',
- coral: '#ff7f50',
- cornflowerblue: '#6495ed',
- cornsilk: '#fff8dc',
- crimson: '#dc143c',
- cyan: '#00ffff',
- darkblue: '#00008b',
- darkcyan: '#008b8b',
- darkgoldenrod: '#b8860b',
- darkgray: '#a9a9a9',
- darkgreen: '#006400',
- darkkhaki: '#bdb76b',
- darkmagenta: '#8b008b',
- darkolivegreen: '#556b2f',
- darkorange: '#ff8c00',
- darkorchid: '#9932cc',
- darkred: '#8b0000',
- darksalmon: '#e9967a',
- darkseagreen: '#8fbc8f',
- darkslateblue: '#483d8b',
- darkslategray: '#2f4f4f',
- darkturquoise: '#00ced1',
- darkviolet: '#9400d3',
- deeppink: '#ff1493',
- deepskyblue: '#00bfff',
- dimgray: '#696969',
- dodgerblue: '#1e90ff',
- firebrick: '#b22222',
- floralwhite: '#fffaf0',
- forestgreen: '#228b22',
- fuchsia: '#ff00ff',
- gainsboro: '#dcdcdc',
- ghostwhite: '#f8f8ff',
- gold: '#ffd700',
- goldenrod: '#daa520',
- gray: '#808080',
- green: '#008000',
- greenyellow: '#adff2f',
- honeydew: '#f0fff0',
- hotpink: '#ff69b4',
- indianred: '#cd5c5c',
- indigo: '#4b0082',
- ivory: '#fffff0',
- khaki: '#f0e68c',
- lavender: '#e6e6fa',
- lavenderblush: '#fff0f5',
- lawngreen: '#7cfc00',
- lemonchiffon: '#fffacd',
- lightblue: '#add8e6',
- lightcoral: '#f08080',
- lightcyan: '#e0ffff',
- lightgoldenrodyellow: '#fafad2',
- lightgray: '#d3d3d3',
- lightgreen: '#90ee90',
- lightpink: '#ffb6c1',
- lightsalmon: '#ffa07a',
- lightseagreen: '#20b2aa',
- lightskyblue: '#87cefa',
- lightslategray: '#778899',
- lightsteelblue: '#b0c4de',
- lightyellow: '#ffffe0',
- lime: '#00ff00',
- limegreen: '#32cd32',
- linen: '#faf0e6',
- magenta: '#ff00ff',
- maroon: '#800000',
- mediumaquamarine: '#66cdaa',
- mediumblue: '#0000cd',
- mediumorchid: '#ba55d3',
- mediumpurple: '#9370db',
- mediumseagreen: '#3cb371',
- mediumslateblue: '#7b68ee',
- mediumspringgreen: '#00fa9a',
- mediumturquoise: '#48d1cc',
- mediumvioletred: '#c71585',
- midnightblue: '#191970',
- mintcream: '#f5fffa',
- mistyrose: '#ffe4e1',
- moccasin: '#ffe4b5',
- navajowhite: '#ffdead',
- navy: '#000080',
- oldlace: '#fdf5e6',
- olive: '#808000',
- olivedrab: '#6b8e23',
- orange: '#ffa500',
- orangered: '#ff4500',
- orchid: '#da70d6',
- palegoldenrod: '#eee8aa',
- palegreen: '#98fb98',
- paleturquoise: '#afeeee',
- palevioletred: '#db7093',
- papayawhip: '#ffefd5',
- peachpuff: '#ffdab9',
- peru: '#cd853f',
- pink: '#ffc0cb',
- plum: '#dda0dd',
- powderblue: '#b0e0e6',
- purple: '#800080',
- red: '#ff0000',
- rosybrown: '#bc8f8f',
- royalblue: '#4169e1',
- saddlebrown: '#8b4513',
- salmon: '#fa8072',
- sandybrown: '#f4a460',
- seagreen: '#2e8b57',
- seashell: '#fff5ee',
- sienna: '#a0522d',
- silver: '#c0c0c0',
- skyblue: '#87ceeb',
- slateblue: '#6a5acd',
- slategray: '#708090',
- snow: '#fffafa',
- springgreen: '#00ff7f',
- steelblue: '#4682b4',
- tan: '#d2b48c',
- teal: '#008080',
- thistle: '#d8bfd8',
- tomato: '#ff6347',
- turquoise: '#40e0d0',
- violet: '#ee82ee',
- wheat: '#f5deb3',
- white: '#ffffff',
- whitesmoke: '#f5f5f5',
- yellow: '#ffff00',
- yellowgreen: '#9acd32'
- };
-
- var isUndefined = function(x) {
- return x === undefined;
- };
-
- var isNotUndefined = function(x) {
- return !isUndefined(x);
- };
-
- var convertToInt = function(x) {
- return parseInt(x);
- };
-
- var convertToRgbInt = function(x) {
- return convertToInt(clamp(number(x), N255));
- };
-
- /* color */
- var Color = function(r, g, b, a) {
- var that = this;
- that.r = that.g = that.b = 0;
- that.a = 1;
-
- if(isNotUndefined(a)) that.a = clamp(number(a), 1);
- if(isNotUndefined(r) && isNotUndefined(g) && isNotUndefined(b)) {
- that.r = convertToRgbInt(r);
- that.g = convertToRgbInt(g);
- that.b = convertToRgbInt(b);
- } else if(isNotUndefined(r)) {
- var type = typeof(r);
- if(type == STR_STRING) {
- r = r.toLowerCase();
- if(r === 'transparent') {
- that.a = 0;
- } else if(namedColors[r]) {
- this.rgb(hexToRgb(namedColors[r]));
- } else {
- that.rgb(hexToRgb(r));
- }
- } else if(type == 'number' && isUndefined(g)) {
- that.r = that.g = that.b = convertToRgbInt(r);
- } else if(type == STR_OBJECT && isNotUndefined(r.r)) {
- that.r = convertToRgbInt(r.r);
- if(isNotUndefined(r.g)) that.g = convertToRgbInt(r.g);
- if(isNotUndefined(r.b)) that.b = convertToRgbInt(r.b);
- if(isNotUndefined(r.a)) that.a = clamp(number(r.a), 1);
- } else if(type == STR_OBJECT && isNotUndefined(r.h)) {
- var hsl = {
- h: clamp(number(r.h), N360),
- s: 1,
- l: 1,
- a: 1
- };
- if(isNotUndefined(r.s)) hsl.s = clamp(number(r.s), 1);
- if(isNotUndefined(r.l)) hsl.l = clamp(number(r.l), 1);
- if(isNotUndefined(r.a)) hsl.a = clamp(number(r.a), 1);
-
- that.rgb(hslToRgb(hsl));
- }
- }
- };
-
- Color.prototype.rgb = function(rgb) {
- var that = this;
- if(isNotUndefined(rgb)) {
- if(typeof(rgb) == STR_OBJECT) {
- if(isNotUndefined(rgb.r)) that.r = convertToRgbInt(rgb.r);
- if(isNotUndefined(rgb.g)) that.g = convertToRgbInt(rgb.g);
- if(isNotUndefined(rgb.b)) that.b = convertToRgbInt(rgb.b);
- if(isNotUndefined(rgb.a)) that.a = clamp(number(rgb.a), 1);
- } else {
- var v = convertToInt(number(rgb));
- that.r = v;
- that.g = v;
- that.b = v;
- }
- return that;
- } else return {
- r: that.r,
- g: that.g,
- b: that.b,
- a: that.a
- };
- };
-
- Color.prototype.hue = function(hue) {
- var that = this;
- var hsl = that.toHsl();
-
- if(isUndefined(hue)) return hsl.h;
- else {
- hsl.h = clamp(number(hue), N360);
- that.rgb(hslToRgb(hsl));
- return that;
- }
- };
-
- Color.prototype.darken = function(amount) {
- var that = this;
- var hsl = that.toHsl();
-
- hsl.l -= amount / N100;
- hsl.l = clamp(hsl.l, 1);
-
- that.rgb(hslToRgb(hsl));
- return that;
- };
-
- Color.prototype.clone = function() {
- var that = this;
- return new Color(that.r, that.g, that.b, that.a);
- };
-
- Color.prototype.lighten = function(amount) {
- return this.darken(-amount);
- };
-
- Color.prototype.fade = function(amount) {
- this.a = clamp(amount / N100, 1);
-
- return this;
- };
-
- Color.prototype.spin = function(amount) {
- var hsl = this.toHsl();
- var hue = (hsl.h + amount) % N360;
-
- hsl.h = hue < 0 ? N360 + hue : hue;
- return this.rgb(hslToRgb(hsl));
- };
-
- Color.prototype.toHsl = function() {
- var that = this;
- var r = that.r / N255,
- g = that.g / N255,
- b = that.b / N255,
- a = that.a;
-
- var max = Math.max(r, g, b),
- min = Math.min(r, g, b);
- var h, s, l = (max + min) / 2,
- d = max - min;
-
- if(max === min) {
- h = s = 0;
- } else {
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
-
- switch(max) {
- case r:
- h = (g - b) / d + (g < b ? 6 : 0);
- break;
- case g:
- h = (b - r) / d + 2;
- break;
- case b:
- h = (r - g) / d + 4;
- break;
- }
- h /= 6;
- }
- return {
- h: h * N360,
- s: s,
- l: l,
- a: a
- };
- };
-
- Color.prototype.luma = function() {
- var r = this.r / N255,
- g = this.g / N255,
- b = this.b / N255;
-
- r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);
- g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);
- b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);
-
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
- };
-
- Color.prototype.saturate = function(amount) {
- var hsl = this.toHsl();
-
- hsl.s += amount / N100;
- hsl.s = clamp(hsl.s);
-
- return this.rgb(hslToRgb(hsl));
- };
-
- Color.prototype.desaturate = function(amount) {
- return this.saturate(-amount);
- };
-
- Color.prototype.contrast = function(dark, light, threshold) {
- if(isUndefined(light)) light = new Color(N255, N255, N255, 1);
- else light = new Color(light);
- if(isUndefined(dark)) dark = new Color(0, 0, 0, 1);
- else dark = new Color(dark);
-
- if(dark.luma() > light.luma()) {
- var t = light;
- light = dark;
- dark = t;
- }
-
- if(this.a < 0.5) return dark;
-
- if(isUndefined(threshold)) threshold = 0.43;
- else threshold = number(threshold);
-
- if(this.luma() < threshold) {
- return light;
- } else {
- return dark;
- }
- };
-
- Color.prototype.hexStr = function() {
- var r = this.r.toString(16),
- g = this.g.toString(16),
- b = this.b.toString(16);
- if(r.length == 1) r = '0' + r;
- if(g.length == 1) g = '0' + g;
- if(b.length == 1) b = '0' + b;
-
- return '#' + r + g + b;
- };
-
- Color.prototype.toCssStr = function() {
- var that = this;
- if(that.a > 0) {
- if(that.a < 1) {
- return 'rgba(' + that.r + ',' + that.g + ',' + that.b + ',' + that.a + ')';
- } else {
- return that.hexStr();
- }
- } else {
- return 'transparent';
- }
- };
-
- Color.isColor = isColor;
- Color.names = namedColors;
-
- Color.get = function(colorName) {
- return new Color(colorName);
- };
-
- /* helpers */
- function hexToRgb(hex) {
- hex = hex.toLowerCase();
- if(hex && hexReg.test(hex)) {
- var i;
- if(hex.length === 4) {
- var hexNew = '#';
- for(i = 1; i < 4; i += 1) {
- hexNew += hex.slice(i, i + 1).concat(hex.slice(i, i + 1));
- }
- hex = hexNew;
- }
-
- var hexChange = [];
- for(i = 1; i < 7; i += 2) {
- hexChange.push(convertToInt('0x' + hex.slice(i, i + 2)));
- }
- return {
- r: hexChange[0],
- g: hexChange[1],
- b: hexChange[2],
- a: 1
- };
- } else {
- throw new Error('Wrong hex string! (hex: ' + hex + ')');
- }
- }
-
- function isColor(hex) {
- return typeof(hex) === STR_STRING && (hex.toLowerCase() === 'transparent' || namedColors[hex.toLowerCase()] || hexReg.test($.trim(hex.toLowerCase())));
- }
-
- function hslToRgb(hsl) {
- var h = hsl.h,
- s = hsl.s,
- l = hsl.l,
- a = hsl.a;
-
- h = (number(h) % N360) / N360;
- s = clamp(number(s));
- l = clamp(number(l));
- a = clamp(number(a));
-
- var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
- var m1 = l * 2 - m2;
-
- var r = {
- r: hue(h + 1 / 3) * N255,
- g: hue(h) * N255,
- b: hue(h - 1 / 3) * N255,
- a: a
- };
-
- return r;
-
- function hue(h) {
- h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
- if(h * 6 < 1) {
- return m1 + (m2 - m1) * h * 6;
- } else if(h * 2 < 1) {
- return m2;
- } else if(h * 3 < 2) {
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
- } else {
- return m1;
- }
- }
- }
-
- function fit(n, end, start) {
- if(isUndefined(start)) start = 0;
- if(isUndefined(end)) end = N255;
-
- return Math.min(Math.max(n, start), end);
- }
-
- function clamp(v, max) {
- return fit(v, max);
- }
-
- function number(n) {
- if(typeof(n) == 'number') return n;
- return parseFloat(n);
- }
-
- $.zui({
- Color: Color
- });
-
-}(jQuery, Math, window, undefined));
-
-/* ========================================================================
- * Chart.js: Chart.Core.js [Version: 1.0.2]
- * http://chartjs.org/
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2015 Nick Downie, Released under the MIT license
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
- * ======================================================================== */
-
-
-/*!
+function(t,e,i){"$:nomunge";function s(){n=e[r](function(){a.each(function(){var e=t(this),i=e.width(),s=e.height(),n=t.data(this,h);i===n.w&&s===n.h||e.trigger(l,[n.w=i,n.h=s])}),s()},o[c])}var n,a=t([]),o=t.resize=t.extend(t.resize,{}),r="setTimeout",l="resize",h=l+"-special-event",c="delay",d="throttleWindow";o[c]=250,o[d]=!0,t.event.special[l]={setup:function(){if(!o[d]&&this[r])return!1;var e=t(this);a=a.add(e),t.data(this,h,{w:e.width(),h:e.height()}),1===a.length&&s()},teardown:function(){if(!o[d]&&this[r])return!1;var e=t(this);a=a.not(e),e.removeData(h),a.length||clearTimeout(n)},add:function(e){function s(e,s,a){var o=t(this),r=t.data(this,h)||{};r.w=s!==i?s:o.width(),r.h=a!==i?a:o.height(),n.apply(this,arguments)}if(!o[d]&&this[r])return!1;var n;return t.isFunction(e)?(n=e,s):(n=e.handler,void(e.handler=s))}}}(jQuery,this),function(t,e){"use strict";var i,s,n="localStorage",a="page_"+t.location.pathname+t.location.search,o=function(){this.slience=!0;try{n in t&&t[n]&&t[n].setItem&&(this.enable=!0,i=t[n])}catch(o){}this.enable||(s={},i={getLength:function(){var t=0;return e.each(s,function(){t++}),t},key:function(t){var i,n=0;return e.each(s,function(e){return n===t?(i=e,!1):void n++}),i},removeItem:function(t){delete s[t]},getItem:function(t){return s[t]},setItem:function(t,e){s[t]=e},clear:function(){s={}}}),this.storage=i,this.page=this.get(a,{})};o.prototype.pageSave=function(){if(e.isEmptyObject(this.page))this.remove(a);else{var t,i=[];for(t in this.page){var s=this.page[t];null===s&&i.push(t)}for(t=i.length-1;t>=0;t--)delete this.page[i[t]];this.set(a,this.page)}},o.prototype.pageRemove=function(t){"undefined"!=typeof this.page[t]&&(this.page[t]=null,this.pageSave())},o.prototype.pageClear=function(){this.page={},this.pageSave()},o.prototype.pageGet=function(t,e){var i=this.page[t];return void 0===e||null!==i&&void 0!==i?i:e},o.prototype.pageSet=function(t,i){e.isPlainObject(t)?e.extend(!0,this.page,t):this.page[this.serialize(t)]=i,this.pageSave()},o.prototype.check=function(){if(!this.enable&&!this.slience)throw new Error("Browser not support localStorage or enable status been set true.");return this.enable},o.prototype.length=function(){return this.check()?i.getLength?i.getLength():i.length:0},o.prototype.removeItem=function(t){return i.removeItem(t),this},o.prototype.remove=function(t){return this.removeItem(t)},o.prototype.getItem=function(t){return i.getItem(t)},o.prototype.get=function(t,e){var i=this.deserialize(this.getItem(t));return"undefined"!=typeof i&&null!==i||"undefined"==typeof e?i:e},o.prototype.key=function(t){return i.key(t)},o.prototype.setItem=function(t,e){return i.setItem(t,e),this},o.prototype.set=function(t,e){return void 0===e?this.remove(t):(this.setItem(t,this.serialize(e)),this)},o.prototype.clear=function(){return i.clear(),this},o.prototype.forEach=function(t){for(var e=this.length(),s=e-1;s>=0;s--){var n=i.key(s);t(n,this.get(n))}return this},o.prototype.getAll=function(){var t={};return this.forEach(function(e,i){t[e]=i}),t},o.prototype.serialize=function(t){return"string"==typeof t?t:JSON.stringify(t)},o.prototype.deserialize=function(t){if("string"==typeof t)try{return JSON.parse(t)}catch(e){return t||void 0}},e.zui({store:new o})}(window,jQuery),function(t){"use strict";var e="zui.searchBox",i=function(e,s){var n=this;n.name=name,n.$=t(e),n.options=s=t.extend({},i.DEFAULTS,n.$.data(),s);var a=n.$.is(s.inputSelector)?n.$:n.$.find(s.inputSelector);if(a.length){var o=function(){n.changeTimer&&(clearTimeout(n.changeTimer),n.changeTimer=null)},r=function(){o();var t=n.getSearch();if(t!==n.lastValue){var e=""===t;a.toggleClass("empty",e),n.$.callComEvent(n,"onSearchChange",[t,e]),n.lastValue=t}};n.$input=a=a.first(),n.lastValue=n.getSearch(),a.on(s.listenEvent,function(t){n.changeTimer=setTimeout(function(){r()},s.changeDelay)}).on("focus",function(t){a.addClass("focus"),n.$.callComEvent(n,"onFocus",[t])}).on("blur",function(t){a.removeClass("focus"),n.$.callComEvent(n,"onBlur",[t])}).on("keydown",function(t){var e=0,i=t.which;27===i&&s.escToClear?(this.setSearch("",!0),r(),e=1):13===i&&s.onPressEnter&&(r(),n.$.callComEvent(n,"onPressEnter",[t]));var a=n.$.callComEvent(n,"onKeyDown",[t]);a===!1&&(e=1),e&&t.preventDefault()}),n.$.on("click",".search-clear-btn",function(t){n.setSearch("",!0),r(),t.preventDefault()}),r()}else console.error("ZUI: search box init error, cannot find search box input element.")};i.DEFAULTS={inputSelector:'input[type="search"],input[type="text"]',listenEvent:"change input paste",changeDelay:500},i.prototype.getSearch=function(){return this.$input&&t.trim(this.$input.val())},i.prototype.setSearch=function(t,e){var i=this.$input;i&&(i.val(t),e||i.trigger("change"))},i.prototype.focus=function(){this.$input&&this.$input.focus()},t.fn.searchBox=function(s){return this.each(function(){var n=t(this),a=n.data(e),o="object"==typeof s&&s;a||n.data(e,a=new i(this,o)),"string"==typeof s&&a[s]()})},i.NAME=e,t.fn.searchBox.Constructor=i}(jQuery),function(t,e){"use strict";var i="zui.draggable",s={container:"body",move:!0},n=0,a=function(e,i){var a=this;a.$=t(e),a.id=n++,a.options=t.extend({},s,a.$.data(),i),a.init()};a.DEFAULTS=s,a.NAME=i,a.prototype.init=function(){var s,n,a,o,r,l=this,h=l.$,c="before",d="drag",u="finish",p="."+i+"."+l.id,f="mousedown"+p,g="mouseup"+p,m="mousemove"+p,v=l.options,y=v.selector,b=v.handle,w=h,x=t.isFunction(v.move),_=function(t){var e=t.pageX,i=t.pageY;r=!0;var n={left:e-a.x,top:i-a.y};w.removeClass("drag-ready").addClass("dragging"),v.move&&(x?v.move(n,w):w.css(n)),v[d]&&v[d]({event:t,element:w,startOffset:a,pos:n,offset:{x:e-s.x,y:i-s.y},smallOffset:{x:e-o.x,y:i-o.y}}),o.x=e,o.y=i,v.stopPropagation&&t.stopPropagation()},C=function(i){if(t(e).off(p),!r)return void w.removeClass("drag-ready");var n={left:i.pageX-a.x,top:i.pageY-a.y};w.removeClass("drag-ready dragging"),v.move&&(x?v.move(n,w):w.css(n)),v[u]&&v[u]({event:i,element:w,startOffset:a,pos:n,offset:{x:i.pageX-s.x,y:i.pageY-s.y},smallOffset:{x:i.pageX-o.x,y:i.pageY-o.y}}),i.preventDefault(),v.stopPropagation&&i.stopPropagation()},k=function(i){var l=t.zui.getMouseButtonCode(v.mouseButton);if(!(l>-1&&i.button!==l)){var h=t(this);if(y&&(w=b?h.closest(y):h),v[c]){var d=v[c]({event:i,element:w});if(d===!1)return}var u=t(v.container),p=w.offset();n=u.offset(),s={x:i.pageX,y:i.pageY},a={x:i.pageX-p.left+n.left,y:i.pageY-p.top+n.top},o=t.extend({},s),r=!1,w.addClass("drag-ready"),i.preventDefault(),v.stopPropagation&&i.stopPropagation(),t(e).on(m,_).on(g,C)}};b?h.on(f,b,k):y?h.on(f,y,k):h.on(f,k)},a.prototype.destroy=function(){var s="."+i+"."+this.id;this.$.off(s),t(e).off(s),this.$.data(i,null)},t.fn.draggable=function(e){return this.each(function(){var s=t(this),n=s.data(i),o="object"==typeof e&&e;n||s.data(i,n=new a(this,o)),"string"==typeof e&&n[e]()})},t.fn.draggable.Constructor=a}(jQuery,document),function(t,e,i){"use strict";var s="zui.droppable",n={target:".droppable-target",deviation:5,sensorOffsetX:0,sensorOffsetY:0},a=0,o=function(e,i){var s=this;s.id=a++,s.$=t(e),s.options=t.extend({},n,s.$.data(),i),s.init()};o.DEFAULTS=n,o.NAME=s,o.prototype.trigger=function(e,i){return t.zui.callEvent(this.options[e],i,this)},o.prototype.init=function(){var n,a,o,r,l,h,c,d,u,p,f,g,m,v=this,y=v.$,b=v.options,w=b.deviation,x="."+s+"."+v.id,_="mousedown"+x,C="mouseup"+x,k="mousemove"+x,T=b.selector,S=b.handle,D=b.flex,M=b.container,P=b.canMoveHere,F=y,L=!1,z=M?t(b.container).first():T?y:t("body"),$=function(e){if(L&&(f={left:e.pageX,top:e.pageY},!(i.abs(f.left-d.left) a&&f.top>o&&f.left-1&&i.button!==s)){var f=t(this);T&&(F=S?f.closest(T):f),F.hasClass("drag-shadow")||b.before&&b.before({event:i,element:F})===!1||(L=!0,n=t.isFunction(b.target)?b.target(y):z.find(b.target),a=null,o=null,r=!1,l=!0,h=null,c=F.offset(),u=z.offset(),d={left:i.pageX,top:i.pageY},g=t.extend({},d),p={left:d.left-c.left,top:d.top-c.top},F.addClass("drag-from"),t(e).on(k,$).on(C,E),m=setTimeout(function(){t(e).on(_,E)},10),i.preventDefault())}};S?y.on(_,S,I):T?y.on(_,T,I):y.on(_,I)},o.prototype.destroy=function(){var i="."+s+"."+this.id;this.$.off(i),t(e).off(i),this.$.data(s,null)},o.prototype.reset=function(){this.destroy(),this.init()},t.fn.droppable=function(e){return this.each(function(){var i=t(this),n=i.data(s),a="object"==typeof e&&e;n||i.data(s,n=new o(this,a)),"string"==typeof e&&n[e]()})},t.fn.droppable.Constructor=o}(jQuery,document,Math),+function(t,e){"use strict";function i(e,i,a){return this.each(function(){var o=t(this),r=o.data(s),l=t.extend({},n.DEFAULTS,o.data(),"object"==typeof e&&e);r||o.data(s,r=new n(this,l)),"string"==typeof e?r[e](i,a):l.show&&r.show(i,a)})}var s="zui.modal",n=function(i,n){var a=this;a.options=n,a.$body=t(document.body),a.$element=t(i),a.$backdrop=a.isShown=null,a.scrollbarWidth=0,n.moveable===e&&(a.options.moveable=a.$element.hasClass("modal-moveable")),n.remote&&a.$element.find(".modal-content").load(n.remote,function(){a.$element.trigger("loaded."+s)})};n.VERSION="3.2.0",n.TRANSITION_DURATION=300,n.BACKDROP_TRANSITION_DURATION=150,n.DEFAULTS={backdrop:!0,keyboard:!0,show:!0,position:"fit"};var a=function(e,i){var s=t(window);i.left=Math.max(0,Math.min(i.left,s.width()-e.outerWidth())),i.top=Math.max(0,Math.min(i.top,s.height()-e.outerHeight())),e.css(i)};n.prototype.toggle=function(t,e){return this.isShown?this.hide():this.show(t,e)},n.prototype.ajustPosition=function(i){var n=this,o=n.options;if(i===e&&(i=o.position),i!==e){t.isFunction(i)&&(i=i(n));var r=n.$element.find(".modal-dialog"),l=Math.max(0,(t(window).height()-r.outerHeight())/2);if("fit"===i?i={marginTop:2*l/3}:"center"===i?i={marginTop:l}:t.isPlainObject(i)||(i={marginTop:i}),r.hasClass("modal-moveable")){var h=null,c=o.rememberPos;c&&(c===!0?h=n.$element.data("modal-pos"):t.zui.store&&(h=t.zui.store.pageGet(s+".rememberPos."+c))),i=t.extend(i,{left:Math.max(0,(t(window).width()-r.outerWidth())/2)},h),"inside"===o.moveable?a(r,i):r.css(i)}else r.css(i)}},n.prototype.setMoveale=function(){t.fn.draggable||console.error("Moveable modal requires draggable.js.");var e=this,i=e.options,n=e.$element.find(".modal-dialog").removeClass("modal-dragged");n.toggleClass("modal-moveable",!!i.moveable),e.$element.data("modal-moveable-setup")||n.draggable({container:e.$element,handle:".modal-header",before:function(){var t=n.css("margin-top");t&&"0px"!==t&&n.css("top",t).css("margin-top","").addClass("modal-dragged")},finish:function(n){var a=i.rememberPos;a&&(e.$element.data("modal-pos",n.pos),t.zui.store&&a!==!0&&t.zui.store.pageSet(s+".rememberPos."+a,n.pos))},move:"inside"!==i.moveable||function(t){a(n,t)}})},n.prototype.show=function(e,i){var a=this,o=t.Event("show."+s,{relatedTarget:e});a.$element.trigger(o),a.isShown||o.isDefaultPrevented()||(a.isShown=!0,a.options.moveable&&a.setMoveale(),a.checkScrollbar(),a.options.backdrop!==!1&&(a.$body.addClass("modal-open"),a.setScrollbar()),a.escape(),a.$element.on("click.dismiss."+s,'[data-dismiss="modal"]',t.proxy(a.hide,a)),a.backdrop(function(){var o=t.support.transition&&a.$element.hasClass("fade");a.$element.parent().length||a.$element.appendTo(a.$body),a.$element.show().scrollTop(0),o&&a.$element[0].offsetWidth,a.$element.addClass("in").attr("aria-hidden",!1),a.ajustPosition(i),a.enforceFocus();var r=t.Event("shown."+s,{relatedTarget:e});o?a.$element.find(".modal-dialog").one("bsTransitionEnd",function(){a.$element.trigger("focus").trigger(r)}).emulateTransitionEnd(n.TRANSITION_DURATION):a.$element.trigger("focus").trigger(r)}))},n.prototype.hide=function(e){e&&e.preventDefault();var i=this;e=t.Event("hide."+s),i.$element.trigger(e),i.isShown&&!e.isDefaultPrevented()&&(i.isShown=!1,i.options.backdrop!==!1&&(i.$body.removeClass("modal-open"),i.resetScrollbar()),i.escape(),t(document).off("focusin."+s),i.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss."+s),t.support.transition&&i.$element.hasClass("fade")?i.$element.one("bsTransitionEnd",t.proxy(i.hideModal,i)).emulateTransitionEnd(n.TRANSITION_DURATION):i.hideModal())},n.prototype.enforceFocus=function(){t(document).off("focusin."+s).on("focusin."+s,t.proxy(function(t){this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},n.prototype.escape=function(){this.isShown&&this.options.keyboard?t(document).on("keydown.dismiss."+s,t.proxy(function(i){if(27==i.which){var n=t.Event("escaping."+s),a=this.$element.triggerHandler(n,"esc");if(a!=e&&!a)return;this.hide()}},this)):this.isShown||t(document).off("keydown.dismiss."+s)},n.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$element.trigger("hidden."+s)})},n.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},n.prototype.backdrop=function(e){var i=this,a=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var o=t.support.transition&&a;if(this.$backdrop=t('').appendTo(this.$body),this.$element.on("mousedown.dismiss."+s,t.proxy(function(t){t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus.call(this.$element[0]):this.hide.call(this))},this)),o&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!e)return;o?this.$backdrop.one("bsTransitionEnd",e).emulateTransitionEnd(n.BACKDROP_TRANSITION_DURATION):e()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var r=function(){i.removeBackdrop(),e&&e()};t.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",r).emulateTransitionEnd(n.BACKDROP_TRANSITION_DURATION):r()}else e&&e()},n.prototype.checkScrollbar=function(){document.body.clientWidth>=window.innerWidth||(this.scrollbarWidth=this.scrollbarWidth||this.measureScrollbar())},n.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.scrollbarWidth&&this.$body.css("padding-right",t+this.scrollbarWidth)},n.prototype.resetScrollbar=function(){this.$body.css("padding-right","")},n.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var o=t.fn.modal;t.fn.modal=i,t.fn.modal.Constructor=n,t.fn.modal.noConflict=function(){return t.fn.modal=o,this},t(document).on("click."+s+".data-api",'[data-toggle="modal"]',function(e){var n=t(this),a=n.attr("href"),o=null;try{o=t(n.attr("data-target")||a&&a.replace(/.*(?=#[^\s]+$)/,""))}catch(r){return}if(o.length){var l=o.data(s)?"toggle":t.extend({remote:!/#/.test(a)&&a},o.data(),n.data());n.is("a")&&e.preventDefault(),o.one("show."+s,function(t){t.isDefaultPrevented()||o.one("hidden."+s,function(){n.is(":visible")&&n.trigger("focus")})}),i.call(o,l,this,n.data("position"))}})}(jQuery,void 0),function(t,e,i){"use strict";if(!t.fn.modal)throw new Error("Modal trigger requires modal.js");var s="zui.modaltrigger",n="ajax",a=".zui.modal",o="string",r=function(e,i){e=t.extend({},r.DEFAULTS,t.ModalTriggerDefaults,i?i.data():null,e),this.isShown,this.$trigger=i,this.options=e,this.id=t.zui.uuid()};r.DEFAULTS={type:"custom",height:"auto",name:"triggerModal",fade:!0,position:"fit",showHeader:!0,delay:0,backdrop:!0,keyboard:!0,waittime:0,loadingIcon:"icon-spinner-indicator"},r.prototype.init=function(i){var r=this;if(i.url&&(!i.type||i.type!=n&&"iframe"!=i.type)&&(i.type=n),i.remote)i.type=n,typeof i.remote===o&&(i.url=i.remote);else if(i.iframe)i.type="iframe",typeof i.iframe===o&&(i.url=i.iframe);else if(i.custom&&(i.type="custom",typeof i.custom===o)){var l;try{l=t(i.custom)}catch(h){}l&&l.length?i.custom=l:t.isFunction(e[i.custom])&&(i.custom=e[i.custom])}var c=t("#"+i.name);c.length&&(r.isShown||c.off(a),c.remove()),c=t(''+("string"==typeof i.loadingIcon&&0===i.loadingIcon.indexOf("icon-")?' ':i.loadingIcon)+' ').appendTo("body").data(s,r);var d=function(e,s){var n=i[e];t.isFunction(n)&&c.on(s+a,n)};d("onShow","show"),d("shown","shown"),d("onHide","hide"),d("hidden","hidden"),d("loaded","loaded"),c.on("shown"+a,function(){r.isShown=!0}).on("hidden"+a,function(){r.isShown=!1}),this.$modal=c,this.$dialog=c.find(".modal-dialog"),i.mergeOptions&&(this.options=i)},r.prototype.show=function(i){var a=t.extend({},this.options,{url:this.$trigger?this.$trigger.attr("href")||this.$trigger.attr("data-url")||this.$trigger.data("url"):this.options.url},i);this.init(a);var r=this,l=this.$modal,h=this.$dialog,c=a.custom,d=h.find(".modal-body").css("padding",""),u=h.find(".modal-header"),p=h.find(".modal-content");l.toggleClass("fade",a.fade).addClass(a.className).toggleClass("modal-loading",!this.isShown),h.toggleClass("modal-md","md"===a.size).toggleClass("modal-sm","sm"===a.size).toggleClass("modal-lg","lg"===a.size).toggleClass("modal-fullscreen","fullscreen"===a.size),u.toggle(a.showHeader),u.find(".modal-icon").attr("class","modal-icon icon-"+a.icon),u.find(".modal-title-name").text(a.title||""),a.size&&"fullscreen"===a.size&&(a.width="",a.height="");var f=function(){clearTimeout(this.resizeTask),this.resizeTask=setTimeout(function(){r.ajustPosition(a.position)},100)},g=function(t,e){return"undefined"==typeof t&&(t=a.delay),setTimeout(function(){h=l.find(".modal-dialog"),a.width&&"auto"!=a.width&&h.css("width",a.width),a.height&&"auto"!=a.height&&(h.css("height",a.height),"iframe"===a.type&&d.css("height",h.height()-u.outerHeight())),r.ajustPosition(a.position),l.removeClass("modal-loading"),"iframe"!=a.type&&h.off("resize."+s).on("resize."+s,f),e&&e()},t)};if("custom"===a.type&&c)if(t.isFunction(c)){var m=c({modal:l,options:a,modalTrigger:r,ready:g});typeof m===o&&(d.html(m),g())}else c instanceof t?(d.html(t("").append(c.clone()).html()),g()):(d.html(c),g());else if(a.url){var v=function(){var t=l.callComEvent(r,"broken");t&&(d.html(t),g())};if(l.attr("ref",a.url),"iframe"===a.type){l.addClass("modal-iframe"),this.firstLoad=!0;var y="iframe-"+a.name;u.detach(),d.detach(),p.empty().append(u).append(d),d.css("padding",0).html(' '),a.waittime>0&&(r.waitTimeout=g(a.waittime,v));var b=document.getElementById(y);b.onload=b.onreadystatechange=function(){if(r.firstLoad&&l.addClass("modal-loading"),!this.readyState||"complete"==this.readyState){r.firstLoad=!1,a.waittime>0&&clearTimeout(r.waitTimeout);try{l.attr("ref",b.contentWindow.location.href);var t=e.frames[y].$;if(t&&"auto"===a.height&&"fullscreen"!=a.size){var i=t("body").addClass("body-modal");a.iframeBodyClass&&i.addClass(a.iframeBodyClass);var n=function(t){l.removeClass("fade");var e=i.outerHeight();t===!0&&a.onlyIncreaseHeight&&(e=Math.max(e,d.data("minModalHeight")||0),d.data("minModalHeight",e)),d.css("height",e),a.fade&&l.addClass("fade"),g()};l.callComEvent(r,"loaded",{modalType:"iframe",jQuery:t}),setTimeout(n,100),i.off("resize."+s).on("resize."+s,f)}else g();t.extend({closeModal:e.closeModal})}catch(o){g()}}}}else t.ajax(t.extend({url:a.url,success:function(i){try{var s=t(i);s.filter(".modal-dialog").length?h.replaceWith(s):s.filter(".modal-content").length?h.find(".modal-content").replaceWith(s):d.wrapInner(s)}catch(a){e.console&&e.console.warn&&console.warn("ZUI: Cannot recogernize remote content.",{error:a,data:i}),l.html(i)}l.callComEvent(r,"loaded",{modalType:n}),g()},error:v},a.ajaxOptions))}l.modal({show:"show",backdrop:a.backdrop,moveable:a.moveable,rememberPos:a.rememberPos,keyboard:a.keyboard})},r.prototype.close=function(i,s){(i||s)&&this.$modal.on("hidden"+a,function(){t.isFunction(i)&&i(),typeof s===o&&("this"===s?e.location.reload():e.location=s)}),this.$modal.modal("hide")},r.prototype.toggle=function(t){this.isShown?this.close():this.show(t)},r.prototype.ajustPosition=function(e){e=e===i?this.options.position:e,t.isFunction(e)&&(e=e(this)),this.$modal.modal("ajustPosition",e)},t.zui({ModalTrigger:r,modalTrigger:new r}),t.fn.modalTrigger=function(e,i){return t(this).each(function(){var n=t(this),a=n.data(s),l=t.extend({title:n.attr("title")||n.text(),url:n.attr("href"),type:n.hasClass("iframe")?"iframe":""},n.data(),t.isPlainObject(e)&&e);a||n.data(s,a=new r(l,n)),typeof e==o?a[e](i):l.show&&a.show(i),n.on((l.trigger||"click")+".toggle."+s,function(t){a.toggle(l),n.is("a")&&t.preventDefault()})})};var l=t.fn.modal;t.fn.modal=function(e,i){return t(this).each(function(){var s=t(this);s.hasClass("modal")?l.call(s,e,i):s.modalTrigger(e,i)})};var h=function(e){var i=typeof e;return"undefined"===i?e=t(".modal.modal-trigger"):i===o&&(e=t(e)),e&&e instanceof t?e:null},c=function(e,i,n){if(t.isFunction(e)){var a=n;n=i,i=e,e=a}e=h(e),e&&e.length&&e.each(function(){t(this).data(s).close(i,n)})},d=function(t,e){e=h(e),e&&e.length&&e.modal("ajustPosition",t)};t.zui({closeModal:c,ajustModalPosition:d}),t(document).on("click."+s+".data-api",'[data-toggle="modal"]',function(e){var i=t(this),n=i.attr("href"),a=null;try{a=t(i.attr("data-target")||n&&n.replace(/.*(?=#[^\s]+$)/,""))}catch(o){}a&&a.length||(i.data(s)?i.trigger(".toggle."+s):i.modalTrigger({show:!0})),i.is("a")&&e.preventDefault()})}(window.jQuery,window,void 0),+function(t){"use strict";var e=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.init("tooltip",t,e)};e.DEFAULTS={animation:!0,placement:"top",selector:!1,template:' ',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},e.prototype.init=function(e,i,s){this.enabled=!0,this.type=e,this.$element=t(i),this.options=this.getOptions(s);for(var n=this.options.trigger.split(" "),a=n.length;a--;){var o=n[a];if("click"==o)this.$element.on("click."+this.type,this.options.selector,t.proxy(this.toggle,this));else if("manual"!=o){var r="hover"==o?"mouseenter":"focus",l="hover"==o?"mouseleave":"blur";this.$element.on(r+"."+this.type,this.options.selector,t.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,t.proxy(this.leave,this))}}this.options.selector?this._options=t.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},e.prototype.getDefaults=function(){return e.DEFAULTS},e.prototype.getOptions=function(e){return e=t.extend({},this.getDefaults(),this.$element.data(),e),e.delay&&"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),e},e.prototype.getDelegateOptions=function(){var e={},i=this.getDefaults();return this._options&&t.each(this._options,function(t,s){i[t]!=s&&(e[t]=s)}),e},e.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget)[this.type](this.getDelegateOptions()).data("zui."+this.type);return clearTimeout(i.timeout),i.hoverState="in",i.options.delay&&i.options.delay.show?void(i.timeout=setTimeout(function(){"in"==i.hoverState&&i.show()},i.options.delay.show)):i.show()},e.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget)[this.type](this.getDelegateOptions()).data("zui."+this.type);return clearTimeout(i.timeout),i.hoverState="out",i.options.delay&&i.options.delay.hide?void(i.timeout=setTimeout(function(){"out"==i.hoverState&&i.hide()},i.options.delay.hide)):i.hide()},e.prototype.show=function(e){var i=t.Event("show.zui."+this.type);if((e||this.hasContent())&&this.enabled){var s=this;if(s.$element.trigger(i),i.isDefaultPrevented())return;var n=s.tip();s.setContent(e),s.options.animation&&n.addClass("fade");var a="function"==typeof s.options.placement?s.options.placement.call(s,n[0],s.$element[0]):s.options.placement,o=/\s?auto?\s?/i,r=o.test(a);r&&(a=a.replace(o,"")||"top"),n.detach().css({top:0,left:0,display:"block"}).addClass(a),s.options.container?n.appendTo(s.options.container):n.insertAfter(s.$element);var l=s.getPosition(),h=n[0].offsetWidth,c=n[0].offsetHeight;if(r){var d=s.$element.parent(),u=a,p=document.documentElement.scrollTop||document.body.scrollTop,f="body"==s.options.container?window.innerWidth:d.outerWidth(),g="body"==s.options.container?window.innerHeight:d.outerHeight(),m="body"==s.options.container?0:d.offset().left;a="bottom"==a&&l.top+l.height+c-p>g?"top":"top"==a&&l.top-p-c<0?"bottom":"right"==a&&l.right+h>f?"left":"left"==a&&l.left-h '}),e.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),e.prototype.constructor=e,e.prototype.getDefaults=function(){return e.DEFAULTS},e.prototype.setContent=function(){var t=this.tip(),e=this.getTarget();if(e)return e.find(".arrow").length<1&&t.addClass("no-arrow"),void t.html(e.html());var i=this.getTitle(),s=this.getContent();t.find(".popover-title")[this.options.html?"html":"text"](i),t.find(".popover-content")[this.options.html?"html":"text"](s),t.removeClass("fade top bottom left right in"),this.options.tipId&&t.attr("id",this.options.tipId),this.options.tipClass&&t.addClass(this.options.tipClass),t.find(".popover-title").html()||t.find(".popover-title").hide()},e.prototype.hasContent=function(){return this.getTarget()||this.getTitle()||this.getContent()},e.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},e.prototype.getTarget=function(){var e=this.$element,i=this.options,s=e.attr("data-target")||("function"==typeof i.target?i.target.call(e[0]):i.target);return!!s&&("$next"==s?e.next(".popover"):t(s))},e.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},e.prototype.tip=function(){return this.$tip||(this.$tip=t(this.options.template)),this.$tip};var i=t.fn.popover;t.fn.popover=function(i){
+return this.each(function(){var s=t(this),n=s.data("zui.popover"),a="object"==typeof i&&i;n||s.data("zui.popover",n=new e(this,a)),"string"==typeof i&&n[i]()})},t.fn.popover.Constructor=e,t.fn.popover.noConflict=function(){return t.fn.popover=i,this}}(window.jQuery),+function(t){"use strict";function e(){t(n).remove(),t(a).each(function(e){var n=i(t(this));n.hasClass("open")&&(n.trigger(e=t.Event("hide."+s)),e.isDefaultPrevented()||n.removeClass("open").trigger("hidden."+s))})}function i(e){var i=e.attr("data-target");i||(i=e.attr("href"),i=i&&/#/.test(i)&&i.replace(/.*(?=#[^\s]*$)/,""));var s;try{s=i&&t(i)}catch(n){}return s&&s.length?s:e.parent()}var s="zui.dropdown",n=".dropdown-backdrop",a="[data-toggle=dropdown]",o=function(e){t(e).on("click."+s,this.toggle)};o.prototype.toggle=function(n){var a=t(this);if(!a.is(".disabled, :disabled")){var o=i(a),r=o.hasClass("open");if(e(),!r){if("ontouchstart"in document.documentElement&&!o.closest(".navbar-nav").length&&t('').insertAfter(t(this)).on("click",e),o.trigger(n=t.Event("show."+s)),n.isDefaultPrevented())return;o.toggleClass("open").trigger("shown."+s),a.focus()}return!1}},o.prototype.keydown=function(e){if(/(38|40|27)/.test(e.keyCode)){var s=t(this);if(e.preventDefault(),e.stopPropagation(),!s.is(".disabled, :disabled")){var n=i(s),o=n.hasClass("open");if(!o||o&&27==e.keyCode)return 27==e.which&&n.find(a).focus(),s.click();var r=t("[role=menu] li:not(.divider):visible a",n);if(r.length){var l=r.index(r.filter(":focus"));38==e.keyCode&&l>0&&l--,40==e.keyCode&&l ',a={type:"default",placement:"top",time:4e3,parent:"body",icon:null,close:!0,fade:!0,scale:!0},o={},r=function(e,r){t.isPlainObject(e)&&(r=e,e=r.message);var l=this;r=l.options=t.extend({},a,r),l.id=r.id||s++;var h=o[l.id];h&&h.destroy(),o[l.id]=l,l.message=(r.icon?' ':"")+e,l.$=t(n.format(r)).toggleClass("fade",r.fade).toggleClass("scale",r.scale).attr("id","messager-"+l.id),r.cssClass&&l.$.addClass(r.cssClass);var c=!1,d=l.$.find(".messager-actions"),u=function(e){var s=t('');"close"===e.name&&s.addClass("close"),e.html!==i&&s.html(e.html),e.icon!==i&&s.append(''),e.text!==i&&s.append(''+e.text+""),e.tooltip!==i&&s.attr("title",e.tooltip).tooltip(),s.data("action",e),d.append(s)};r.actions&&t.each(r.actions,function(t,e){e.name===i&&(e.name=t),"close"==e.name&&(c=!0),u(e)}),!c&&r.close&&u({name:"close",html:"×"}),l.$.on("click",".action",function(e){var i,s=t(this).data("action");r.onAction&&(i=r.onAction.call(this,s.name,s,l),i===!1)||t.isFunction(s.action)&&(i=s.action.call(this,l),i===!1)||(l.hide(),e.stopPropagation())}),l.$.on("click",function(t){if(r.onAction){var e=r.onAction.call(this,"content",null,l);e===!0&&l.hide()}});var p=l.$.find(".messager-content").html(l.message);r.contentClass&&p.addClass(r.contentClass),l.$.data("zui.messager",l),r.show&&l.message!==i&&l.show()};r.prototype.update=function(e,i){var s=this,n=s.options;s.$.removeClass("messager-"+n.type),i&&(n=t.extend(n,i)),s.$.addClass("messager-"+n.type),e&&(s.message=(n.icon?' ':"")+e,s.$.find(".messager-content").html(s.message))},r.prototype.show=function(s,n){var a=this,o=this.options;if(t.isFunction(s)){var r=n;n=s,r!==i&&(s=r)}if(a.isShow)return void a.hide(function(){a.show(s,n)});a.hiding&&(clearTimeout(a.hiding),a.hiding=null),a.update(s);var l=o.placement,h=t(o.parent),c=h.children(".messagers-holder."+l);if(c.length||(c=t("").attr("class","messagers-holder "+l).appendTo(h)),c.append(a.$),"center"===l){var d=t(e).height()-c.height();c.css("top",Math.max(-d,d/2))}return a.$.show().addClass("in"),o.time&&(a.hiding=setTimeout(function(){a.hide()},o.time)),a.isShow=!0,n&&n(),a},r.prototype.hide=function(t,e){t===!0&&(e=!0,t=null);var i=this;if(i.$.hasClass("in")){i.$.removeClass("in");var s=function(){var e=i.$.parent();i.$.detach(),e.children().length||e.remove(),t&&t(!0)};e?s():setTimeout(s,200)}else t&&t(!1);i.isShow=!1},r.prototype.destroy=function(){var t=this;t.hide(function(){t.$.remove(),t.$=null},!0),delete o[t.id]},r.all=o,r.DEFAULTS=a;var l=function(){t(".messager").each(function(){var e=t(this).data("zui.messager");e&&e.hide&&e.hide(!0)})},h=function(e,s){"string"==typeof s&&(s={type:s}),s=t.extend({},s),s.id===i&&l();var n=o[s.id]||new r(e,s);return n.show(),n},c=function(t){return"string"==typeof t?{placement:t}:t},d={show:h,hide:l};t.each({primary:0,success:"ok-sign",info:"info-sign",warning:"warning-sign",danger:"exclamation-sign",important:0,special:0},function(e,i){d[e]=function(s,n){return h(s,t.extend({type:e,icon:i||null},c(n)))}}),t.zui({Messager:r,showMessager:h,messager:d})}(jQuery,window,void 0),function(t,e,i,s){"use strict";function n(t){if(t=t.toLowerCase(),t&&c.test(t)){var e;if(4===t.length){var i="#";for(e=1;e<4;e+=1)i+=t.slice(e,e+1).concat(t.slice(e,e+1));t=i}var s=[];for(e=1;e<7;e+=2)s.push(b("0x"+t.slice(e,e+2)));return{r:s[0],g:s[1],b:s[2],a:1}}throw new Error("Wrong hex string! (hex: "+t+")")}function a(e){return typeof e===f&&("transparent"===e.toLowerCase()||m[e.toLowerCase()]||c.test(t.trim(e.toLowerCase())))}function o(t){function e(t){return t=t<0?t+1:t>1?t-1:t,6*t<1?r+(o-r)*t*6:2*t<1?o:3*t<2?r+(o-r)*(2/3-t)*6:r}var i=t.h,s=t.s,n=t.l,a=t.a;i=h(i)%u/u,s=l(h(s)),n=l(h(n)),a=l(h(a));var o=n<=.5?n*(s+1):n+s-n*s,r=2*n-o,c={r:e(i+1/3)*d,g:e(i)*d,b:e(i-1/3)*d,a:a};return c}function r(t,i,s){return v(s)&&(s=0),v(i)&&(i=d),e.min(e.max(t,s),i)}function l(t,e){return r(t,e)}function h(t){return"number"==typeof t?t:parseFloat(t)}var c=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,d=255,u=360,p=100,f="string",g="object",m={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},v=function(t){return t===s},y=function(t){return!v(t)},b=function(t){return parseInt(t)},w=function(t){return b(l(h(t),d))},x=function(t,e,i,s){var a=this;if(a.r=a.g=a.b=0,a.a=1,y(s)&&(a.a=l(h(s),1)),y(t)&&y(e)&&y(i))a.r=w(t),a.g=w(e),a.b=w(i);else if(y(t)){var r=typeof t;if(r==f)t=t.toLowerCase(),"transparent"===t?a.a=0:m[t]?this.rgb(n(m[t])):a.rgb(n(t));else if("number"==r&&v(e))a.r=a.g=a.b=w(t);else if(r==g&&y(t.r))a.r=w(t.r),y(t.g)&&(a.g=w(t.g)),y(t.b)&&(a.b=w(t.b)),y(t.a)&&(a.a=l(h(t.a),1));else if(r==g&&y(t.h)){var c={h:l(h(t.h),u),s:1,l:1,a:1};y(t.s)&&(c.s=l(h(t.s),1)),y(t.l)&&(c.l=l(h(t.l),1)),y(t.a)&&(c.a=l(h(t.a),1)),a.rgb(o(c))}}};x.prototype.rgb=function(t){var e=this;if(y(t)){if(typeof t==g)y(t.r)&&(e.r=w(t.r)),y(t.g)&&(e.g=w(t.g)),y(t.b)&&(e.b=w(t.b)),y(t.a)&&(e.a=l(h(t.a),1));else{var i=b(h(t));e.r=i,e.g=i,e.b=i}return e}return{r:e.r,g:e.g,b:e.b,a:e.a}},x.prototype.hue=function(t){var e=this,i=e.toHsl();return v(t)?i.h:(i.h=l(h(t),u),e.rgb(o(i)),e)},x.prototype.darken=function(t){var e=this,i=e.toHsl();return i.l-=t/p,i.l=l(i.l,1),e.rgb(o(i)),e},x.prototype.clone=function(){var t=this;return new x(t.r,t.g,t.b,t.a)},x.prototype.lighten=function(t){return this.darken(-t)},x.prototype.fade=function(t){return this.a=l(t/p,1),this},x.prototype.spin=function(t){var e=this.toHsl(),i=(e.h+t)%u;return e.h=i<0?u+i:i,this.rgb(o(e))},x.prototype.toHsl=function(){var t,i,s=this,n=s.r/d,a=s.g/d,o=s.b/d,r=s.a,l=e.max(n,a,o),h=e.min(n,a,o),c=(l+h)/2,p=l-h;if(l===h)t=i=0;else{switch(i=c>.5?p/(2-l-h):p/(l+h),l){case n:t=(a-o)/p+(ae.luma()){var s=e;e=t,t=s}return this.a<.5?t:(i=v(i)?.43:h(i),this.luma()0?t.a<1?"rgba("+t.r+","+t.g+","+t.b+","+t.a+")":t.hexStr():"transparent"},x.isColor=a,x.names=m,x.get=function(t){return new x(t)},t.zui({Color:x})}(jQuery,Math,window,void 0),/*!
* Chart.js 1.0.2
* Copyright 2015 Nick Downie
* Released under the MIT license
* http://chartjs.org/
*/
-
-/// ----- ZUI change begin -----
-/// Add jquery object to namespace
-
-/// (function(){ // Old code
-(function($) {
-
- /// ----- ZUI change end -----
-
-
- "use strict";
-
- //Declare root variable - window in the browser, global on the server
- /// ----- ZUI change begin -----
- /// Change root to zui shared object
- ///
- /// var root = this, // old code
- var root = $ && $.zui ? $.zui : this,
- /// ----- ZUI change end -----
- previous = root.Chart;
-
- //Occupy the global variable of Chart, and create a simple base class
- var Chart = function(context) {
- var chart = this;
- this.canvas = context.canvas;
-
- this.ctx = context;
-
- //Variables global to the chart
- var computeDimension = function(element, dimension) {
- if(element['offset' + dimension]) {
- return element['offset' + dimension];
- } else {
- return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
- }
- }
-
- var width = this.width = computeDimension(context.canvas, 'Width');
- var height = this.height = computeDimension(context.canvas, 'Height');
-
- // Firefox requires this to work correctly
- context.canvas.width = width;
- context.canvas.height = height;
-
- var width = this.width = context.canvas.width;
- var height = this.height = context.canvas.height;
- this.aspectRatio = this.width / this.height;
- //High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale.
- helpers.retinaScale(this);
-
- return this;
- };
-
- //Globally expose the defaults to allow for user updating/changing
- Chart.defaults = {
- global: {
- // Boolean - Whether to animate the chart
- animation: true,
-
- // Number - Number of animation steps
- animationSteps: 60,
-
- // String - Animation easing effect
- // Possible effects are:
- // [easeInOutQuart, linear, easeOutBounce, easeInBack, easeInOutQuad,
- // easeOutQuart, easeOutQuad, easeInOutBounce, easeOutSine, easeInOutCubic,
- // easeInExpo, easeInOutBack, easeInCirc, easeInOutElastic, easeOutBack,
- // easeInQuad, easeInOutExpo, easeInQuart, easeOutQuint, easeInOutCirc,
- // easeInSine, easeOutExpo, easeOutCirc, easeOutCubic, easeInQuint,
- // easeInElastic, easeInOutSine, easeInOutQuint, easeInBounce,
- // easeOutElastic, easeInCubic]
- animationEasing: "easeOutQuart",
-
- // Boolean - If we should show the scale at all
- showScale: true,
-
- // Boolean - If we want to override with a hard coded scale
- scaleOverride: false,
-
- // ** Required if scaleOverride is true **
- // Number - The number of steps in a hard coded scale
- scaleSteps: null,
- // Number - The value jump in the hard coded scale
- scaleStepWidth: null,
- // Number - The scale starting value
- scaleStartValue: null,
-
- // String - Colour of the scale line
- scaleLineColor: "rgba(0,0,0,.1)",
-
- // Number - Pixel width of the scale line
- scaleLineWidth: 1,
-
- // Boolean - Whether to show labels on the scale
- scaleShowLabels: true,
-
- // Interpolated JS string - can access value
- scaleLabel: "<%=value%>",
-
- // Boolean - Whether the scale should stick to integers, and not show any floats even if drawing space is there
- scaleIntegersOnly: true,
-
- // Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
- scaleBeginAtZero: false,
-
- // String - Scale label font declaration for the scale label
- scaleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
-
- // Number - Scale label font size in pixels
- scaleFontSize: 12,
-
- // String - Scale label font weight style
- scaleFontStyle: "normal",
-
- // String - Scale label font colour
- scaleFontColor: "#666",
-
- // Boolean - whether or not the chart should be responsive and resize when the browser does.
- responsive: false,
-
- // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
- maintainAspectRatio: true,
-
- // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
- showTooltips: true,
-
- // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function
- customTooltips: false,
-
- // Array - Array of string names to attach tooltip events
- tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"],
-
- // String - Tooltip background colour
- tooltipFillColor: "rgba(0,0,0,0.8)",
-
- // String - Tooltip label font declaration for the scale label
- tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
-
- // Number - Tooltip label font size in pixels
- tooltipFontSize: 14,
-
- // String - Tooltip font weight style
- tooltipFontStyle: "normal",
-
- // String - Tooltip label font colour
- tooltipFontColor: "#fff",
-
- // String - Tooltip title font declaration for the scale label
- tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
-
- // Number - Tooltip title font size in pixels
- tooltipTitleFontSize: 14,
-
- // String - Tooltip title font weight style
- tooltipTitleFontStyle: "bold",
-
- // String - Tooltip title font colour
- tooltipTitleFontColor: "#fff",
-
- // Number - pixel width of padding around tooltip text
- tooltipYPadding: 6,
-
- // Number - pixel width of padding around tooltip text
- tooltipXPadding: 6,
-
- // Number - Size of the caret on the tooltip
- tooltipCaretSize: 8,
-
- // Number - Pixel radius of the tooltip border
- tooltipCornerRadius: 6,
-
- // Number - Pixel offset from point x to tooltip edge
- tooltipXOffset: 10,
-
- // String - Template string for single tooltips
- tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
-
- // String - Template string for single tooltips
- multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",
-
- // String - Colour behind the legend colour block
- multiTooltipKeyBackground: '#fff',
-
- // Function - Will fire on animation progression.
- onAnimationProgress: function() {},
-
- // Function - Will fire on animation completion.
- onAnimationComplete: function() {}
-
- }
- };
-
- //Create a dictionary of chart types, to allow for extension of existing types
- Chart.types = {};
-
- //Global Chart helpers object for utility methods and classes
- var helpers = Chart.helpers = {};
-
- //-- Basic js utility methods
- var each = helpers.each = function(loopable, callback, self) {
- var additionalArgs = Array.prototype.slice.call(arguments, 3);
- // Check to see if null or undefined firstly.
- if(loopable) {
- if(loopable.length === +loopable.length) {
- var i;
- for(i = 0; i < loopable.length; i++) {
- callback.apply(self, [loopable[i], i].concat(additionalArgs));
- }
- } else {
- for(var item in loopable) {
- callback.apply(self, [loopable[item], item].concat(additionalArgs));
- }
- }
- }
- },
- clone = helpers.clone = function(obj) {
- var objClone = {};
- each(obj, function(value, key) {
- if(obj.hasOwnProperty(key)) objClone[key] = value;
- });
- return objClone;
- },
- extend = helpers.extend = function(base) {
- each(Array.prototype.slice.call(arguments, 1), function(extensionObject) {
- each(extensionObject, function(value, key) {
- if(extensionObject.hasOwnProperty(key)) base[key] = value;
- });
- });
- return base;
- },
- merge = helpers.merge = function(base, master) {
- //Merge properties in left object over to a shallow clone of object right.
- var args = Array.prototype.slice.call(arguments, 0);
- args.unshift({});
- return extend.apply(null, args);
- },
- indexOf = helpers.indexOf = function(arrayToSearch, item) {
- if(Array.prototype.indexOf) {
- return arrayToSearch.indexOf(item);
- } else {
- for(var i = 0; i < arrayToSearch.length; i++) {
- if(arrayToSearch[i] === item) return i;
- }
- return -1;
- }
- },
- where = helpers.where = function(collection, filterCallback) {
- var filtered = [];
-
- helpers.each(collection, function(item) {
- if(filterCallback(item)) {
- filtered.push(item);
- }
- });
-
- return filtered;
- },
- findNextWhere = helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) {
- // Default to start of the array
- if(!startIndex) {
- startIndex = -1;
- }
- for(var i = startIndex + 1; i < arrayToSearch.length; i++) {
- var currentItem = arrayToSearch[i];
- if(filterCallback(currentItem)) {
- return currentItem;
- }
- }
- },
- findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) {
- // Default to end of the array
- if(!startIndex) {
- startIndex = arrayToSearch.length;
- }
- for(var i = startIndex - 1; i >= 0; i--) {
- var currentItem = arrayToSearch[i];
- if(filterCallback(currentItem)) {
- return currentItem;
- }
- }
- },
- inherits = helpers.inherits = function(extensions) {
- //Basic javascript inheritance based on the model created in Backbone.js
- var parent = this;
- var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() {
- return parent.apply(this, arguments);
- };
-
- var Surrogate = function() {
- this.constructor = ChartElement;
- };
- Surrogate.prototype = parent.prototype;
- ChartElement.prototype = new Surrogate();
-
- ChartElement.extend = inherits;
-
- if(extensions) extend(ChartElement.prototype, extensions);
-
- ChartElement.__super__ = parent.prototype;
-
- return ChartElement;
- },
- noop = helpers.noop = function() {},
- uid = helpers.uid = (function() {
- var id = 0;
- return function() {
- return "chart-" + id++;
- };
- })(),
- warn = helpers.warn = function(str) {
- //Method for warning of errors
- if(window.console && typeof window.console.warn == "function") console.warn(str);
- },
- amd = helpers.amd = (typeof define == 'function' && define.amd),
- //-- Math methods
- isNumber = helpers.isNumber = function(n) {
- return !isNaN(parseFloat(n)) && isFinite(n);
- },
- max = helpers.max = function(array) {
- return Math.max.apply(Math, array);
- },
- min = helpers.min = function(array) {
- return Math.min.apply(Math, array);
- },
- cap = helpers.cap = function(valueToCap, maxValue, minValue) {
- if(isNumber(maxValue)) {
- if(valueToCap > maxValue) {
- return maxValue;
- }
- } else if(isNumber(minValue)) {
- if(valueToCap < minValue) {
- return minValue;
- }
- }
- return valueToCap;
- },
- getDecimalPlaces = helpers.getDecimalPlaces = function(num) {
- if(num % 1 !== 0 && isNumber(num)) {
- return num.toString().split(".")[1].length;
- } else {
- return 0;
- }
- },
- toRadians = helpers.radians = function(degrees) {
- return degrees * (Math.PI / 180);
- },
- // Gets the angle from vertical upright to the point about a centre.
- getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) {
- var distanceFromXCenter = anglePoint.x - centrePoint.x,
- distanceFromYCenter = anglePoint.y - centrePoint.y,
- radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);
-
-
- var angle = Math.PI * 2 + Math.atan2(distanceFromYCenter, distanceFromXCenter);
-
- //If the segment is in the top left quadrant, we need to add another rotation to the angle
- if(distanceFromXCenter < 0 && distanceFromYCenter < 0) {
- angle += Math.PI * 2;
- }
-
- return {
- angle: angle,
- distance: radialDistanceFromCenter
- };
- },
- aliasPixel = helpers.aliasPixel = function(pixelWidth) {
- return(pixelWidth % 2 === 0) ? 0 : 0.5;
- },
- splineCurve = helpers.splineCurve = function(FirstPoint, MiddlePoint, AfterPoint, t) {
- //Props to Rob Spencer at scaled innovation for his post on splining between points
- //http://scaledinnovation.com/analytics/splines/aboutSplines.html
- var d01 = Math.sqrt(Math.pow(MiddlePoint.x - FirstPoint.x, 2) + Math.pow(MiddlePoint.y - FirstPoint.y, 2)),
- d12 = Math.sqrt(Math.pow(AfterPoint.x - MiddlePoint.x, 2) + Math.pow(AfterPoint.y - MiddlePoint.y, 2)),
- fa = t * d01 / (d01 + d12), // scaling factor for triangle Ta
- fb = t * d12 / (d01 + d12);
- return {
- inner: {
- x: MiddlePoint.x - fa * (AfterPoint.x - FirstPoint.x),
- y: MiddlePoint.y - fa * (AfterPoint.y - FirstPoint.y)
- },
- outer: {
- x: MiddlePoint.x + fb * (AfterPoint.x - FirstPoint.x),
- y: MiddlePoint.y + fb * (AfterPoint.y - FirstPoint.y)
- }
- };
- },
- calculateOrderOfMagnitude = helpers.calculateOrderOfMagnitude = function(val) {
- return Math.floor(Math.log(val) / Math.LN10);
- },
- calculateScaleRange = helpers.calculateScaleRange = function(valuesArray, drawingSize, textSize, startFromZero, integersOnly) {
-
- //Set a minimum step of two - a point at the top of the graph, and a point at the base
- var minSteps = 2,
- maxSteps = Math.floor(drawingSize / (textSize * 1.5)),
- skipFitting = (minSteps >= maxSteps);
-
- var maxValue = max(valuesArray),
- minValue = min(valuesArray);
-
- // We need some degree of seperation here to calculate the scales if all the values are the same
- // Adding/minusing 0.5 will give us a range of 1.
- if(maxValue === minValue) {
- maxValue += 0.5;
- // So we don't end up with a graph with a negative start value if we've said always start from zero
- if(minValue >= 0.5 && !startFromZero) {
- minValue -= 0.5;
- } else {
- // Make up a whole number above the values
- maxValue += 0.5;
- }
- }
-
- var valueRange = Math.abs(maxValue - minValue),
- rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange),
- graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude),
- graphMin = (startFromZero) ? 0 : Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude),
- graphRange = graphMax - graphMin,
- stepValue = Math.pow(10, rangeOrderOfMagnitude),
- numberOfSteps = Math.round(graphRange / stepValue);
-
- //If we have more space on the graph we'll use it to give more definition to the data
- while((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) {
- if(numberOfSteps > maxSteps) {
- stepValue *= 2;
- numberOfSteps = Math.round(graphRange / stepValue);
- // Don't ever deal with a decimal number of steps - cancel fitting and just use the minimum number of steps.
- if(numberOfSteps % 1 !== 0) {
- skipFitting = true;
- }
- }
- //We can fit in double the amount of scale points on the scale
- else {
- //If user has declared ints only, and the step value isn't a decimal
- if(integersOnly && rangeOrderOfMagnitude >= 0) {
- //If the user has said integers only, we need to check that making the scale more granular wouldn't make it a float
- if(stepValue / 2 % 1 === 0) {
- stepValue /= 2;
- numberOfSteps = Math.round(graphRange / stepValue);
- }
- //If it would make it a float break out of the loop
- else {
- break;
- }
- }
- //If the scale doesn't have to be an int, make the scale more granular anyway.
- else {
- stepValue /= 2;
- numberOfSteps = Math.round(graphRange / stepValue);
- }
-
- }
- }
-
- if(skipFitting) {
- numberOfSteps = minSteps;
- stepValue = graphRange / numberOfSteps;
- }
-
- return {
- steps: numberOfSteps,
- stepValue: stepValue,
- min: graphMin,
- max: graphMin + (numberOfSteps * stepValue)
- };
-
- },
- /* jshint ignore:start */
- // Blows up jshint errors based on the new Function constructor
- //Templating methods
- //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
- template = helpers.template = function(templateString, valuesObject) {
-
- // If templateString is function rather than string-template - call the function for valuesObject
-
- if(templateString instanceof Function) {
- return templateString(valuesObject);
- }
-
- var cache = {};
-
- function tmpl(str, data) {
- // Figure out if we're getting a template, or if we need to
- // load the template - and be sure to cache the result.
- var fn = !/\W/.test(str) ?
- cache[str] = cache[str] :
-
- // Generate a reusable function that will serve as a template
- // generator (and which will be cached).
- new Function("obj",
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
-
- // Introduce the data as local variables using with(){}
- "with(obj){p.push('" +
-
- // Convert the template into pure JavaScript
- str
- .replace(/[\r\t\n]/g, " ")
- .split("<%").join("\t")
- .replace(/((^|%>)[^\t]*)'/g, "$1\r")
- .replace(/\t=(.*?)%>/g, "',$1,'")
- .split("\t").join("');")
- .split("%>").join("p.push('")
- .split("\r").join("\\'") +
- "');}return p.join('');"
- );
-
- // Provide some basic currying to the user
- return data ? fn(data) : fn;
- }
- return tmpl(templateString, valuesObject);
- },
- /* jshint ignore:end */
- generateLabels = helpers.generateLabels = function(templateString, numberOfSteps, graphMin, stepValue) {
- var labelsArray = new Array(numberOfSteps);
- if(labelTemplateString) {
- each(labelsArray, function(val, index) {
- labelsArray[index] = template(templateString, {
- value: (graphMin + (stepValue * (index + 1)))
- });
- });
- }
- return labelsArray;
- },
- //--Animation methods
- //Easing functions adapted from Robert Penner's easing equations
- //http://www.robertpenner.com/easing/
- easingEffects = helpers.easingEffects = {
- linear: function(t) {
- return t;
- },
- easeInQuad: function(t) {
- return t * t;
- },
- easeOutQuad: function(t) {
- return -1 * t * (t - 2);
- },
- easeInOutQuad: function(t) {
- if((t /= 1 / 2) < 1) return 1 / 2 * t * t;
- return -1 / 2 * ((--t) * (t - 2) - 1);
- },
- easeInCubic: function(t) {
- return t * t * t;
- },
- easeOutCubic: function(t) {
- return 1 * ((t = t / 1 - 1) * t * t + 1);
- },
- easeInOutCubic: function(t) {
- if((t /= 1 / 2) < 1) return 1 / 2 * t * t * t;
- return 1 / 2 * ((t -= 2) * t * t + 2);
- },
- easeInQuart: function(t) {
- return t * t * t * t;
- },
- easeOutQuart: function(t) {
- return -1 * ((t = t / 1 - 1) * t * t * t - 1);
- },
- easeInOutQuart: function(t) {
- if((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t;
- return -1 / 2 * ((t -= 2) * t * t * t - 2);
- },
- easeInQuint: function(t) {
- return 1 * (t /= 1) * t * t * t * t;
- },
- easeOutQuint: function(t) {
- return 1 * ((t = t / 1 - 1) * t * t * t * t + 1);
- },
- easeInOutQuint: function(t) {
- if((t /= 1 / 2) < 1) return 1 / 2 * t * t * t * t * t;
- return 1 / 2 * ((t -= 2) * t * t * t * t + 2);
- },
- easeInSine: function(t) {
- return -1 * Math.cos(t / 1 * (Math.PI / 2)) + 1;
- },
- easeOutSine: function(t) {
- return 1 * Math.sin(t / 1 * (Math.PI / 2));
- },
- easeInOutSine: function(t) {
- return -1 / 2 * (Math.cos(Math.PI * t / 1) - 1);
- },
- easeInExpo: function(t) {
- return(t === 0) ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1));
- },
- easeOutExpo: function(t) {
- return(t === 1) ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1);
- },
- easeInOutExpo: function(t) {
- if(t === 0) return 0;
- if(t === 1) return 1;
- if((t /= 1 / 2) < 1) return 1 / 2 * Math.pow(2, 10 * (t - 1));
- return 1 / 2 * (-Math.pow(2, -10 * --t) + 2);
- },
- easeInCirc: function(t) {
- if(t >= 1) return t;
- return -1 * (Math.sqrt(1 - (t /= 1) * t) - 1);
- },
- easeOutCirc: function(t) {
- return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t);
- },
- easeInOutCirc: function(t) {
- if((t /= 1 / 2) < 1) return -1 / 2 * (Math.sqrt(1 - t * t) - 1);
- return 1 / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1);
- },
- easeInElastic: function(t) {
- var s = 1.70158;
- var p = 0;
- var a = 1;
- if(t === 0) return 0;
- if((t /= 1) == 1) return 1;
- if(!p) p = 1 * 0.3;
- if(a < Math.abs(1)) {
- a = 1;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(1 / a);
- return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));
- },
- easeOutElastic: function(t) {
- var s = 1.70158;
- var p = 0;
- var a = 1;
- if(t === 0) return 0;
- if((t /= 1) == 1) return 1;
- if(!p) p = 1 * 0.3;
- if(a < Math.abs(1)) {
- a = 1;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(1 / a);
- return a * Math.pow(2, -10 * t) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) + 1;
- },
- easeInOutElastic: function(t) {
- var s = 1.70158;
- var p = 0;
- var a = 1;
- if(t === 0) return 0;
- if((t /= 1 / 2) == 2) return 1;
- if(!p) p = 1 * (0.3 * 1.5);
- if(a < Math.abs(1)) {
- a = 1;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(1 / a);
- if(t < 1) return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p));
- return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * 1 - s) * (2 * Math.PI) / p) * 0.5 + 1;
- },
- easeInBack: function(t) {
- var s = 1.70158;
- return 1 * (t /= 1) * t * ((s + 1) * t - s);
- },
- easeOutBack: function(t) {
- var s = 1.70158;
- return 1 * ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1);
- },
- easeInOutBack: function(t) {
- var s = 1.70158;
- if((t /= 1 / 2) < 1) return 1 / 2 * (t * t * (((s *= (1.525)) + 1) * t - s));
- return 1 / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
- },
- easeInBounce: function(t) {
- return 1 - easingEffects.easeOutBounce(1 - t);
- },
- easeOutBounce: function(t) {
- if((t /= 1) < (1 / 2.75)) {
- return 1 * (7.5625 * t * t);
- } else if(t < (2 / 2.75)) {
- return 1 * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75);
- } else if(t < (2.5 / 2.75)) {
- return 1 * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375);
- } else {
- return 1 * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375);
- }
- },
- easeInOutBounce: function(t) {
- if(t < 1 / 2) return easingEffects.easeInBounce(t * 2) * 0.5;
- return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5;
- }
- },
- //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
- requestAnimFrame = helpers.requestAnimFrame = (function() {
- return window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function(callback) {
- return window.setTimeout(callback, 1000 / 60);
- };
- })(),
- cancelAnimFrame = helpers.cancelAnimFrame = (function() {
- return window.cancelAnimationFrame ||
- window.webkitCancelAnimationFrame ||
- window.mozCancelAnimationFrame ||
- window.oCancelAnimationFrame ||
- window.msCancelAnimationFrame ||
- function(callback) {
- return window.clearTimeout(callback, 1000 / 60);
- };
- })(),
- animationLoop = helpers.animationLoop = function(callback, totalSteps, easingString, onProgress, onComplete, chartInstance) {
-
- var currentStep = 0,
- easingFunction = easingEffects[easingString] || easingEffects.linear;
-
- var animationFrame = function() {
- currentStep++;
- var stepDecimal = currentStep / totalSteps;
- var easeDecimal = easingFunction(stepDecimal);
-
- callback.call(chartInstance, easeDecimal, stepDecimal, currentStep);
- onProgress.call(chartInstance, easeDecimal, stepDecimal);
- if(currentStep < totalSteps) {
- chartInstance.animationFrame = requestAnimFrame(animationFrame);
- } else {
- onComplete.apply(chartInstance);
- }
- };
- requestAnimFrame(animationFrame);
- },
- //-- DOM methods
- getRelativePosition = helpers.getRelativePosition = function(evt) {
- var mouseX, mouseY;
- var e = evt.originalEvent || evt,
- canvas = evt.currentTarget || evt.srcElement,
- boundingRect = canvas.getBoundingClientRect();
-
- if(e.touches) {
- mouseX = e.touches[0].clientX - boundingRect.left;
- mouseY = e.touches[0].clientY - boundingRect.top;
-
- } else {
- mouseX = e.clientX - boundingRect.left;
- mouseY = e.clientY - boundingRect.top;
- }
-
- return {
- x: mouseX,
- y: mouseY
- };
-
- },
- addEvent = helpers.addEvent = function(node, eventType, method) {
- if(node.addEventListener) {
- node.addEventListener(eventType, method);
- } else if(node.attachEvent) {
- node.attachEvent("on" + eventType, method);
- } else {
- node["on" + eventType] = method;
- }
- },
- removeEvent = helpers.removeEvent = function(node, eventType, handler) {
- if(node.removeEventListener) {
- node.removeEventListener(eventType, handler, false);
- } else if(node.detachEvent) {
- node.detachEvent("on" + eventType, handler);
- } else {
- node["on" + eventType] = noop;
- }
- },
- bindEvents = helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) {
- // Create the events object if it's not already present
- if(!chartInstance.events) chartInstance.events = {};
-
- each(arrayOfEvents, function(eventName) {
- chartInstance.events[eventName] = function() {
- handler.apply(chartInstance, arguments);
- };
- addEvent(chartInstance.chart.canvas, eventName, chartInstance.events[eventName]);
- });
- },
- unbindEvents = helpers.unbindEvents = function(chartInstance, arrayOfEvents) {
- each(arrayOfEvents, function(handler, eventName) {
- removeEvent(chartInstance.chart.canvas, eventName, handler);
- });
- },
- getMaximumWidth = helpers.getMaximumWidth = function(domNode) {
- var container = domNode.parentNode;
- // TODO = check cross browser stuff with this.
- return container.clientWidth;
- },
- getMaximumHeight = helpers.getMaximumHeight = function(domNode) {
- var container = domNode.parentNode;
- // TODO = check cross browser stuff with this.
- return container.clientHeight;
- },
- getMaximumSize = helpers.getMaximumSize = helpers.getMaximumWidth, // legacy support
- retinaScale = helpers.retinaScale = function(chart) {
- var ctx = chart.ctx,
- width = chart.canvas.width,
- height = chart.canvas.height;
-
- if(window.devicePixelRatio) {
- ctx.canvas.style.width = width + "px";
- ctx.canvas.style.height = height + "px";
- ctx.canvas.height = height * window.devicePixelRatio;
- ctx.canvas.width = width * window.devicePixelRatio;
- ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
- }
- },
- //-- Canvas methods
- clear = helpers.clear = function(chart) {
- chart.ctx.clearRect(0, 0, chart.width, chart.height);
- },
- fontString = helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
- return fontStyle + " " + pixelSize + "px " + fontFamily;
- },
- longestText = helpers.longestText = function(ctx, font, arrayOfStrings) {
- ctx.font = font;
- var longest = 0;
- each(arrayOfStrings, function(string) {
- var textWidth = ctx.measureText(string).width;
- longest = (textWidth > longest) ? textWidth : longest;
- });
- return longest;
- },
- drawRoundedRectangle = helpers.drawRoundedRectangle = function(ctx, x, y, width, height, radius) {
- ctx.beginPath();
- ctx.moveTo(x + radius, y);
- ctx.lineTo(x + width - radius, y);
- ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
- ctx.lineTo(x + width, y + height - radius);
- ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
- ctx.lineTo(x + radius, y + height);
- ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
- ctx.lineTo(x, y + radius);
- ctx.quadraticCurveTo(x, y, x + radius, y);
- ctx.closePath();
- };
-
-
-
- //Store a reference to each instance - allowing us to globally resize chart instances on window resize.
- //Destroy method on the chart will remove the instance of the chart from this reference.
- Chart.instances = {};
-
- Chart.Type = function(data, options, chart) {
- this.options = options;
- this.chart = chart;
- this.id = uid();
- //Add the chart instance to the global namespace
- Chart.instances[this.id] = this;
-
- // Initialize is always called when a chart type is created
- // By default it is a no op, but it should be extended
- if(options.responsive) {
- this.resize();
- }
- this.initialize.call(this, data);
- };
-
- //Core methods that'll be a part of every chart type
- extend(Chart.Type.prototype, {
- initialize: function() {
- return this;
- },
- clear: function() {
- clear(this.chart);
- return this;
- },
- stop: function() {
- // Stops any current animation loop occuring
- cancelAnimFrame(this.animationFrame);
- return this;
- },
- resize: function(callback) {
- this.stop();
- var canvas = this.chart.canvas,
- newWidth = getMaximumWidth(this.chart.canvas),
- newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas);
-
- canvas.width = this.chart.width = newWidth;
- canvas.height = this.chart.height = newHeight;
-
- retinaScale(this.chart);
-
- if(typeof callback === "function") {
- callback.apply(this, Array.prototype.slice.call(arguments, 1));
- }
- return this;
- },
- reflow: noop,
- render: function(reflow) {
- if(reflow) {
- this.reflow();
- }
- if(this.options.animation && !reflow) {
- helpers.animationLoop(
- this.draw,
- this.options.animationSteps,
- this.options.animationEasing,
- this.options.onAnimationProgress,
- this.options.onAnimationComplete,
- this
- );
- } else {
- this.draw();
- this.options.onAnimationComplete.call(this);
- }
- return this;
- },
- generateLegend: function() {
- return template(this.options.legendTemplate, this);
- },
- destroy: function() {
- this.clear();
- unbindEvents(this, this.events);
- var canvas = this.chart.canvas;
-
- // Reset canvas height/width attributes starts a fresh with the canvas context
- canvas.width = this.chart.width;
- canvas.height = this.chart.height;
-
- // < IE9 doesn't support removeProperty
- if(canvas.style.removeProperty) {
- canvas.style.removeProperty('width');
- canvas.style.removeProperty('height');
- } else {
- canvas.style.removeAttribute('width');
- canvas.style.removeAttribute('height');
- }
-
- delete Chart.instances[this.id];
- },
- showTooltip: function(ChartElements, forceRedraw) {
- // Only redraw the chart if we've actually changed what we're hovering on.
- if(typeof this.activeElements === 'undefined') this.activeElements = [];
-
- var isChanged = (function(Elements) {
- var changed = false;
-
- if(Elements.length !== this.activeElements.length) {
- changed = true;
- return changed;
- }
-
- each(Elements, function(element, index) {
- if(element !== this.activeElements[index]) {
- changed = true;
- }
- }, this);
- return changed;
- }).call(this, ChartElements);
-
- if(!isChanged && !forceRedraw) {
- return;
- } else {
- this.activeElements = ChartElements;
- }
- this.draw();
- if(this.options.customTooltips) {
- this.options.customTooltips(false);
- }
- if(ChartElements.length > 0) {
- // If we have multiple datasets, show a MultiTooltip for all of the data points at that index
- if(this.datasets && this.datasets.length > 1) {
- var dataArray,
- dataIndex;
-
- for(var i = this.datasets.length - 1; i >= 0; i--) {
- dataArray = this.datasets[i].points || this.datasets[i].bars || this.datasets[i].segments;
- dataIndex = indexOf(dataArray, ChartElements[0]);
- if(dataIndex !== -1) {
- break;
- }
- }
- var tooltipLabels = [],
- tooltipColors = [],
- medianPosition = (function(index) {
-
- // Get all the points at that particular index
- var Elements = [],
- dataCollection,
- xPositions = [],
- yPositions = [],
- xMax,
- yMax,
- xMin,
- yMin;
- helpers.each(this.datasets, function(dataset) {
- /// ZUI change begin
- if(dataset.showTooltips === false) return;
- /// ZUI change end
- dataCollection = dataset.points || dataset.bars || dataset.segments;
- if(dataCollection[dataIndex] && dataCollection[dataIndex].hasValue()) {
- Elements.push(dataCollection[dataIndex]);
- }
- });
-
- helpers.each(Elements, function(element) {
- xPositions.push(element.x);
- yPositions.push(element.y);
-
-
- //Include any colour information about the element
- tooltipLabels.push(helpers.template(this.options.multiTooltipTemplate, element));
- tooltipColors.push({
- fill: element._saved.fillColor || element.fillColor,
- stroke: element._saved.strokeColor || element.strokeColor
- });
-
- }, this);
-
- yMin = min(yPositions);
- yMax = max(yPositions);
-
- xMin = min(xPositions);
- xMax = max(xPositions);
-
- return {
- x: (xMin > this.chart.width / 2) ? xMin : xMax,
- y: (yMin + yMax) / 2
- };
- }).call(this, dataIndex);
-
- new Chart.MultiTooltip({
- x: medianPosition.x,
- y: medianPosition.y,
- xPadding: this.options.tooltipXPadding,
- yPadding: this.options.tooltipYPadding,
- xOffset: this.options.tooltipXOffset,
- fillColor: this.options.tooltipFillColor,
- textColor: this.options.tooltipFontColor,
- fontFamily: this.options.tooltipFontFamily,
- fontStyle: this.options.tooltipFontStyle,
- fontSize: this.options.tooltipFontSize,
- titleTextColor: this.options.tooltipTitleFontColor,
- titleFontFamily: this.options.tooltipTitleFontFamily,
- titleFontStyle: this.options.tooltipTitleFontStyle,
- titleFontSize: this.options.tooltipTitleFontSize,
- cornerRadius: this.options.tooltipCornerRadius,
- labels: tooltipLabels,
- legendColors: tooltipColors,
- legendColorBackground: this.options.multiTooltipKeyBackground,
- title: ChartElements[0].label,
- chart: this.chart,
- ctx: this.chart.ctx,
- custom: this.options.customTooltips
- }).draw();
-
- } else {
- each(ChartElements, function(Element) {
- var tooltipPosition = Element.tooltipPosition();
- new Chart.Tooltip({
- x: Math.round(tooltipPosition.x),
- y: Math.round(tooltipPosition.y),
- xPadding: this.options.tooltipXPadding,
- yPadding: this.options.tooltipYPadding,
- fillColor: this.options.tooltipFillColor,
- textColor: this.options.tooltipFontColor,
- fontFamily: this.options.tooltipFontFamily,
- fontStyle: this.options.tooltipFontStyle,
- fontSize: this.options.tooltipFontSize,
- caretHeight: this.options.tooltipCaretSize,
- cornerRadius: this.options.tooltipCornerRadius,
- text: template(this.options.tooltipTemplate, Element),
- chart: this.chart,
- custom: this.options.customTooltips
- }).draw();
- }, this);
- }
- }
- return this;
- },
- toBase64Image: function() {
- return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments);
- }
- });
-
- Chart.Type.extend = function(extensions) {
-
- var parent = this;
-
- var ChartType = function() {
- return parent.apply(this, arguments);
- };
-
- //Copy the prototype object of the this class
- ChartType.prototype = clone(parent.prototype);
- //Now overwrite some of the properties in the base class with the new extensions
- extend(ChartType.prototype, extensions);
-
- ChartType.extend = Chart.Type.extend;
-
- if(extensions.name || parent.prototype.name) {
-
- var chartName = extensions.name || parent.prototype.name;
- //Assign any potential default values of the new chart type
-
- //If none are defined, we'll use a clone of the chart type this is being extended from.
- //I.e. if we extend a line chart, we'll use the defaults from the line chart if our new chart
- //doesn't define some defaults of their own.
-
- var baseDefaults = (Chart.defaults[parent.prototype.name]) ? clone(Chart.defaults[parent.prototype.name]) : {};
-
- Chart.defaults[chartName] = extend(baseDefaults, extensions.defaults);
-
- Chart.types[chartName] = ChartType;
-
- //Register this new chart type in the Chart prototype
- Chart.prototype[chartName] = function(data, options) {
- var config = merge(Chart.defaults.global, Chart.defaults[chartName], options || {});
- return new ChartType(data, config, this);
- };
- } else {
- warn("Name not provided for this chart, so it hasn't been registered");
- }
- return parent;
- };
-
- Chart.Element = function(configuration) {
- extend(this, configuration);
- this.initialize.apply(this, arguments);
- this.save();
- };
- extend(Chart.Element.prototype, {
- initialize: function() {},
- restore: function(props) {
- if(!props) {
- extend(this, this._saved);
- } else {
- each(props, function(key) {
- this[key] = this._saved[key];
- }, this);
- }
- return this;
- },
- save: function() {
- this._saved = clone(this);
- delete this._saved._saved;
- return this;
- },
- update: function(newProps) {
- each(newProps, function(value, key) {
- this._saved[key] = this[key];
- this[key] = value;
- }, this);
- return this;
- },
- transition: function(props, ease) {
- each(props, function(value, key) {
- this[key] = ((value - this._saved[key]) * ease) + this._saved[key];
- }, this);
- return this;
- },
- tooltipPosition: function() {
- return {
- x: this.x,
- y: this.y
- };
- },
- hasValue: function() {
- return isNumber(this.value);
- }
- });
-
- Chart.Element.extend = inherits;
-
-
- Chart.Point = Chart.Element.extend({
- display: true,
- inRange: function(chartX, chartY) {
- var hitDetectionRange = this.hitDetectionRadius + this.radius;
- return((Math.pow(chartX - this.x, 2) + Math.pow(chartY - this.y, 2)) < Math.pow(hitDetectionRange, 2));
- },
- draw: function() {
- if(this.display) {
- var ctx = this.ctx;
- ctx.beginPath();
-
- ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
- ctx.closePath();
-
- ctx.strokeStyle = this.strokeColor;
- ctx.lineWidth = this.strokeWidth;
-
- ctx.fillStyle = this.fillColor;
-
- ctx.fill();
- ctx.stroke();
- }
-
-
- //Quick debug for bezier curve splining
- //Highlights control points and the line between them.
- //Handy for dev - stripped in the min version.
-
- // ctx.save();
- // ctx.fillStyle = "black";
- // ctx.strokeStyle = "black"
- // ctx.beginPath();
- // ctx.arc(this.controlPoints.inner.x,this.controlPoints.inner.y, 2, 0, Math.PI*2);
- // ctx.fill();
-
- // ctx.beginPath();
- // ctx.arc(this.controlPoints.outer.x,this.controlPoints.outer.y, 2, 0, Math.PI*2);
- // ctx.fill();
-
- // ctx.moveTo(this.controlPoints.inner.x,this.controlPoints.inner.y);
- // ctx.lineTo(this.x, this.y);
- // ctx.lineTo(this.controlPoints.outer.x,this.controlPoints.outer.y);
- // ctx.stroke();
-
- // ctx.restore();
-
-
-
- }
- });
-
- Chart.Arc = Chart.Element.extend({
- inRange: function(chartX, chartY) {
-
- var pointRelativePosition = helpers.getAngleFromPoint(this, {
- x: chartX,
- y: chartY
- });
-
- //Check if within the range of the open/close angle
- var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle),
- withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius);
-
- return(betweenAngles && withinRadius);
- //Ensure within the outside of the arc centre, but inside arc outer
- },
- tooltipPosition: function() {
- var centreAngle = this.startAngle + ((this.endAngle - this.startAngle) / 2),
- rangeFromCentre = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius;
- return {
- x: this.x + (Math.cos(centreAngle) * rangeFromCentre),
- y: this.y + (Math.sin(centreAngle) * rangeFromCentre)
- };
- },
- draw: function(animationPercent) {
- var easingDecimal = animationPercent || 1;
-
- var ctx = this.ctx;
-
- ctx.beginPath();
-
- ctx.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle);
-
- ctx.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, true);
-
- ctx.closePath();
-
- ctx.strokeStyle = this.strokeColor;
- ctx.lineWidth = this.strokeWidth;
-
- ctx.fillStyle = this.fillColor;
-
- ctx.fill();
- ctx.lineJoin = 'bevel';
-
- if(this.showStroke) {
- ctx.stroke();
- }
-
- // ZUI change begin
- if (this.circleBeginEnd) {
- var pointCenterRadius = (this.outerRadius + this.innerRadius) / 2;
- var circleRadius = (this.outerRadius - this.innerRadius) / 2;
-
- ctx.beginPath();
- ctx.arc(this.x + Math.cos(this.startAngle) * pointCenterRadius, this.y + Math.sin(this.startAngle) * pointCenterRadius, circleRadius, 0, Math.PI * 2);
- ctx.closePath();
-
- ctx.fill();
-
- ctx.beginPath();
- ctx.arc(this.x + Math.cos(this.endAngle) * pointCenterRadius, this.y + Math.sin(this.endAngle) * pointCenterRadius, circleRadius, 0, Math.PI * 2);
- ctx.closePath();
-
- ctx.fill();
- }
- // ZUI change end
- }
- });
-
- Chart.Rectangle = Chart.Element.extend({
- draw: function() {
- var ctx = this.ctx,
- halfWidth = this.width / 2,
- leftX = this.x - halfWidth,
- rightX = this.x + halfWidth,
- top = this.base - (this.base - this.y),
- halfStroke = this.strokeWidth / 2;
-
- // Canvas doesn't allow us to stroke inside the width so we can
- // adjust the sizes to fit if we're setting a stroke on the line
- if(this.showStroke) {
- leftX += halfStroke;
- rightX -= halfStroke;
- top += halfStroke;
- }
-
- ctx.beginPath();
-
- ctx.fillStyle = this.fillColor;
- ctx.strokeStyle = this.strokeColor;
- ctx.lineWidth = this.strokeWidth;
-
- // It'd be nice to keep this class totally generic to any rectangle
- // and simply specify which border to miss out.
- ctx.moveTo(leftX, this.base);
- ctx.lineTo(leftX, top);
- ctx.lineTo(rightX, top);
- ctx.lineTo(rightX, this.base);
- ctx.fill();
- if(this.showStroke) {
- ctx.stroke();
- }
- },
- height: function() {
- return this.base - this.y;
- },
- inRange: function(chartX, chartY) {
- return(chartX >= this.x - this.width / 2 && chartX <= this.x + this.width / 2) && (chartY >= this.y && chartY <= this.base);
- }
- });
-
- Chart.Tooltip = Chart.Element.extend({
- draw: function() {
-
- var ctx = this.chart.ctx;
-
- ctx.font = fontString(this.fontSize, this.fontStyle, this.fontFamily);
-
- this.xAlign = "center";
- this.yAlign = "above";
-
- //Distance between the actual element.y position and the start of the tooltip caret
- var caretPadding = this.caretPadding = 2;
-
- var tooltipWidth = ctx.measureText(this.text).width + 2 * this.xPadding,
- tooltipRectHeight = this.fontSize + 2 * this.yPadding,
- tooltipHeight = tooltipRectHeight + this.caretHeight + caretPadding;
-
- if(this.x + tooltipWidth / 2 > this.chart.width) {
- this.xAlign = "left";
- } else if(this.x - tooltipWidth / 2 < 0) {
- this.xAlign = "right";
- }
-
- if(this.y - tooltipHeight < 0) {
- this.yAlign = "below";
- }
-
-
- var tooltipX = this.x - tooltipWidth / 2,
- tooltipY = this.y - tooltipHeight;
-
- ctx.fillStyle = this.fillColor;
-
- // Custom Tooltips
- if(this.custom) {
- this.custom(this);
- } else {
- switch(this.yAlign) {
- case "above":
- //Draw a caret above the x/y
- ctx.beginPath();
- ctx.moveTo(this.x, this.y - caretPadding);
- ctx.lineTo(this.x + this.caretHeight, this.y - (caretPadding + this.caretHeight));
- ctx.lineTo(this.x - this.caretHeight, this.y - (caretPadding + this.caretHeight));
- ctx.closePath();
- ctx.fill();
- break;
- case "below":
- tooltipY = this.y + caretPadding + this.caretHeight;
- //Draw a caret below the x/y
- ctx.beginPath();
- ctx.moveTo(this.x, this.y + caretPadding);
- ctx.lineTo(this.x + this.caretHeight, this.y + caretPadding + this.caretHeight);
- ctx.lineTo(this.x - this.caretHeight, this.y + caretPadding + this.caretHeight);
- ctx.closePath();
- ctx.fill();
- break;
- }
-
- switch(this.xAlign) {
- case "left":
- tooltipX = this.x - tooltipWidth + (this.cornerRadius + this.caretHeight);
- break;
- case "right":
- tooltipX = this.x - (this.cornerRadius + this.caretHeight);
- break;
- }
-
- drawRoundedRectangle(ctx, tooltipX, tooltipY, tooltipWidth, tooltipRectHeight, this.cornerRadius);
-
- ctx.fill();
-
- ctx.fillStyle = this.textColor;
- ctx.textAlign = "center";
- ctx.textBaseline = "middle";
- ctx.fillText(this.text, tooltipX + tooltipWidth / 2, tooltipY + tooltipRectHeight / 2);
- }
- }
- });
-
- Chart.MultiTooltip = Chart.Element.extend({
- initialize: function() {
- this.font = fontString(this.fontSize, this.fontStyle, this.fontFamily);
-
- this.titleFont = fontString(this.titleFontSize, this.titleFontStyle, this.titleFontFamily);
-
- this.height = (this.labels.length * this.fontSize) + ((this.labels.length - 1) * (this.fontSize / 2)) + (this.yPadding * 2) + this.titleFontSize * 1.5;
-
- this.ctx.font = this.titleFont;
-
- var titleWidth = this.ctx.measureText(this.title).width,
- //Label has a legend square as well so account for this.
- labelWidth = longestText(this.ctx, this.font, this.labels) + this.fontSize + 3,
- longestTextWidth = max([labelWidth, titleWidth]);
-
- this.width = longestTextWidth + (this.xPadding * 2);
-
-
- var halfHeight = this.height / 2;
-
- //Check to ensure the height will fit on the canvas
- if(this.y - halfHeight < 0) {
- this.y = halfHeight;
- } else if(this.y + halfHeight > this.chart.height) {
- this.y = this.chart.height - halfHeight;
- }
-
- //Decide whether to align left or right based on position on canvas
- if(this.x > this.chart.width / 2) {
- this.x -= this.xOffset + this.width;
- } else {
- this.x += this.xOffset;
- }
-
-
- },
- getLineHeight: function(index) {
- var baseLineHeight = this.y - (this.height / 2) + this.yPadding,
- afterTitleIndex = index - 1;
-
- //If the index is zero, we're getting the title
- if(index === 0) {
- return baseLineHeight + this.titleFontSize / 2;
- } else {
- return baseLineHeight + ((this.fontSize * 1.5 * afterTitleIndex) + this.fontSize / 2) + this.titleFontSize * 1.5;
- }
-
- },
- draw: function() {
- // Custom Tooltips
- if(this.custom) {
- this.custom(this);
- } else {
- drawRoundedRectangle(this.ctx, this.x, this.y - this.height / 2, this.width, this.height, this.cornerRadius);
- var ctx = this.ctx;
- ctx.fillStyle = this.fillColor;
- ctx.fill();
- ctx.closePath();
-
- ctx.textAlign = "left";
- ctx.textBaseline = "middle";
- ctx.fillStyle = this.titleTextColor;
- ctx.font = this.titleFont;
-
- ctx.fillText(this.title, this.x + this.xPadding, this.getLineHeight(0));
-
- ctx.font = this.font;
- helpers.each(this.labels, function(label, index) {
- ctx.fillStyle = this.textColor;
- ctx.fillText(label, this.x + this.xPadding + this.fontSize + 3, this.getLineHeight(index + 1));
-
- //A bit gnarly, but clearing this rectangle breaks when using explorercanvas (clears whole canvas)
- //ctx.clearRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize/2, this.fontSize, this.fontSize);
- //Instead we'll make a white filled block to put the legendColour palette over.
-
- ctx.fillStyle = this.legendColorBackground;
- ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize / 2, this.fontSize, this.fontSize);
-
- ctx.fillStyle = this.legendColors[index].fill;
- ctx.fillRect(this.x + this.xPadding, this.getLineHeight(index + 1) - this.fontSize / 2, this.fontSize, this.fontSize);
-
-
- }, this);
- }
- }
- });
-
- Chart.Scale = Chart.Element.extend({
- initialize: function() {
- this.fit();
- },
- buildYLabels: function() {
- this.yLabels = [];
-
- var stepDecimalPlaces = getDecimalPlaces(this.stepValue);
-
- for(var i = 0; i <= this.steps; i++) {
- this.yLabels.push(template(this.templateString, {
- value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces)
- }));
- }
- this.yLabelWidth = (this.display && this.showLabels) ? longestText(this.ctx, this.font, this.yLabels) : 0;
- },
- addXLabel: function(label) {
- this.xLabels.push(label);
- this.valuesCount++;
- this.fit();
- },
- removeXLabel: function() {
- this.xLabels.shift();
- this.valuesCount--;
- this.fit();
- },
- // Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use
- fit: function() {
- // First we need the width of the yLabels, assuming the xLabels aren't rotated
-
- // To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
- this.startPoint = (this.display) ? this.fontSize : 0;
- this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
-
- // Apply padding settings to the start and end point.
- this.startPoint += this.padding;
- this.endPoint -= this.padding;
-
- // Cache the starting height, so can determine if we need to recalculate the scale yAxis
- var cachedHeight = this.endPoint - this.startPoint,
- cachedYLabelWidth;
-
- // Build the current yLabels so we have an idea of what size they'll be to start
- /*
- * This sets what is returned from calculateScaleRange as static properties of this class:
- *
- this.steps;
- this.stepValue;
- this.min;
- this.max;
- *
- */
- this.calculateYRange(cachedHeight);
-
- // With these properties set we can now build the array of yLabels
- // and also the width of the largest yLabel
- this.buildYLabels();
-
- this.calculateXLabelRotation();
-
- while((cachedHeight > this.endPoint - this.startPoint)) {
- cachedHeight = this.endPoint - this.startPoint;
- cachedYLabelWidth = this.yLabelWidth;
-
- this.calculateYRange(cachedHeight);
- this.buildYLabels();
-
- // Only go through the xLabel loop again if the yLabel width has changed
- if(cachedYLabelWidth < this.yLabelWidth) {
- this.calculateXLabelRotation();
- }
- }
-
- },
- calculateXLabelRotation: function() {
- //Get the width of each grid by calculating the difference
- //between x offsets between 0 and 1.
-
- this.ctx.font = this.font;
-
- var firstWidth = this.ctx.measureText(this.xLabels[0]).width,
- lastWidth = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width,
- firstRotated,
- lastRotated;
-
-
- this.xScalePaddingRight = lastWidth / 2 + 3;
- this.xScalePaddingLeft = (firstWidth / 2 > this.yLabelWidth + 10) ? firstWidth / 2 : this.yLabelWidth + 10;
-
- this.xLabelRotation = 0;
- if(this.display) {
- var originalLabelWidth = longestText(this.ctx, this.font, this.xLabels),
- cosRotation,
- firstRotatedWidth;
- this.xLabelWidth = originalLabelWidth;
- //Allow 3 pixels x2 padding either side for label readability
- var xGridWidth = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6;
-
- //Max label rotate should be 90 - also act as a loop counter
- while((this.xLabelWidth > xGridWidth && this.xLabelRotation === 0) || (this.xLabelWidth > xGridWidth && this.xLabelRotation <= 90 && this.xLabelRotation > 0)) {
- cosRotation = Math.cos(toRadians(this.xLabelRotation));
-
- firstRotated = cosRotation * firstWidth;
- lastRotated = cosRotation * lastWidth;
-
- // We're right aligning the text now.
- if(firstRotated + this.fontSize / 2 > this.yLabelWidth + 8) {
- this.xScalePaddingLeft = firstRotated + this.fontSize / 2;
- }
- this.xScalePaddingRight = this.fontSize / 2;
-
-
- this.xLabelRotation++;
- this.xLabelWidth = cosRotation * originalLabelWidth;
-
- }
- if(this.xLabelRotation > 0) {
- this.endPoint -= Math.sin(toRadians(this.xLabelRotation)) * originalLabelWidth + 3;
- }
- } else {
- this.xLabelWidth = 0;
- this.xScalePaddingRight = this.padding;
- this.xScalePaddingLeft = this.padding;
- }
-
- },
- // Needs to be overidden in each Chart type
- // Otherwise we need to pass all the data into the scale class
- calculateYRange: noop,
- drawingArea: function() {
- return this.startPoint - this.endPoint;
- },
- calculateY: function(value) {
- var scalingFactor = this.drawingArea() / (this.min - this.max);
- return this.endPoint - (scalingFactor * (value - this.min));
- },
- calculateX: function(index) {
- var isRotated = (this.xLabelRotation > 0),
- // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding,
- innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight),
- valueWidth = innerWidth / Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1),
- valueOffset = (valueWidth * index) + this.xScalePaddingLeft;
-
- if(this.offsetGridLines) {
- valueOffset += (valueWidth / 2);
- }
-
- return Math.round(valueOffset);
- },
- update: function(newProps) {
- helpers.extend(this, newProps);
- this.fit();
- },
- draw: function() {
- var ctx = this.ctx,
- yLabelGap = (this.endPoint - this.startPoint) / this.steps,
- xStart = Math.round(this.xScalePaddingLeft);
- if(this.display) {
- ctx.fillStyle = this.textColor;
- ctx.font = this.font;
- var beyondLineLength = this.showBeyondLine ? 5 : 0;
- each(this.yLabels, function(labelString, index) {
- var yLabelCenter = this.endPoint - (yLabelGap * index),
- linePositionY = Math.round(yLabelCenter),
- drawHorizontalLine = this.showHorizontalLines;
-
- ctx.textAlign = "right";
- ctx.textBaseline = "middle";
- if(this.showLabels) {
- ctx.fillText(labelString, xStart - 10, yLabelCenter);
- }
-
- // This is X axis, so draw it
- if(index === 0 && !drawHorizontalLine) {
- drawHorizontalLine = true;
- }
-
- if(drawHorizontalLine) {
- ctx.beginPath();
- }
-
- if(index > 0) {
- // This is a grid line in the centre, so drop that
- ctx.lineWidth = this.gridLineWidth;
- ctx.strokeStyle = this.gridLineColor;
- } else {
- // This is the first line on the scale
- ctx.lineWidth = this.lineWidth;
- ctx.strokeStyle = this.lineColor;
- }
-
- linePositionY += helpers.aliasPixel(ctx.lineWidth);
-
- if(drawHorizontalLine) {
- ctx.moveTo(xStart, linePositionY);
- ctx.lineTo(this.width, linePositionY);
- ctx.stroke();
- ctx.closePath();
- }
-
- ctx.lineWidth = this.lineWidth;
- ctx.strokeStyle = this.lineColor;
- ctx.beginPath();
- ctx.moveTo(xStart - beyondLineLength, linePositionY);
- ctx.lineTo(xStart, linePositionY);
- ctx.stroke();
- ctx.closePath();
-
- }, this);
-
- each(this.xLabels, function(label, index) {
- var xPos = this.calculateX(index) + aliasPixel(this.lineWidth),
- // Check to see if line/bar here and decide where to place the line
- linePos = this.calculateX(index - (this.offsetGridLines ? 0.5 : 0)) + aliasPixel(this.lineWidth),
- isRotated = (this.xLabelRotation > 0),
- drawVerticalLine = this.showVerticalLines;
-
- // This is Y axis, so draw it
- if(index === 0 && !drawVerticalLine) {
- drawVerticalLine = true;
- }
-
- if(drawVerticalLine) {
- ctx.beginPath();
- }
-
- if(index > 0) {
- // This is a grid line in the centre, so drop that
- ctx.lineWidth = this.gridLineWidth;
- ctx.strokeStyle = this.gridLineColor;
- } else {
- // This is the first line on the scale
- ctx.lineWidth = this.lineWidth;
- ctx.strokeStyle = this.lineColor;
- }
-
- if(drawVerticalLine) {
- ctx.moveTo(linePos, this.endPoint);
- ctx.lineTo(linePos, this.startPoint - 3);
- ctx.stroke();
- ctx.closePath();
- }
-
-
- ctx.lineWidth = this.lineWidth;
- ctx.strokeStyle = this.lineColor;
-
-
- // Small lines at the bottom of the base grid line
- ctx.beginPath();
- ctx.moveTo(linePos, this.endPoint);
- ctx.lineTo(linePos, this.endPoint + beyondLineLength);
- ctx.stroke();
- ctx.closePath();
-
- ctx.save();
- ctx.translate(xPos, (isRotated) ? this.endPoint + 12 : this.endPoint + 8);
- ctx.rotate(toRadians(this.xLabelRotation) * -1);
- ctx.font = this.font;
- ctx.textAlign = (isRotated) ? "right" : "center";
- ctx.textBaseline = (isRotated) ? "middle" : "top";
- ctx.fillText(label, 0, 0);
- ctx.restore();
- }, this);
-
- }
- }
-
- });
-
- Chart.RadialScale = Chart.Element.extend({
- initialize: function() {
- this.size = min([this.height, this.width]);
- this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2);
- },
- calculateCenterOffset: function(value) {
- // Take into account half font size + the yPadding of the top value
- var scalingFactor = this.drawingArea / (this.max - this.min);
-
- return(value - this.min) * scalingFactor;
- },
- update: function() {
- if(!this.lineArc) {
- this.setScaleSize();
- } else {
- this.drawingArea = (this.display) ? (this.size / 2) - (this.fontSize / 2 + this.backdropPaddingY) : (this.size / 2);
- }
- this.buildYLabels();
- },
- buildYLabels: function() {
- this.yLabels = [];
-
- var stepDecimalPlaces = getDecimalPlaces(this.stepValue);
-
- for(var i = 0; i <= this.steps; i++) {
- this.yLabels.push(template(this.templateString, {
- value: (this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces)
- }));
- }
- },
- getCircumference: function() {
- return((Math.PI * 2) / this.valuesCount);
- },
- setScaleSize: function() {
- /*
- * Right, this is really confusing and there is a lot of maths going on here
- * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
- *
- * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
- *
- * Solution:
- *
- * We assume the radius of the polygon is half the size of the canvas at first
- * at each index we check if the text overlaps.
- *
- * Where it does, we store that angle and that index.
- *
- * After finding the largest index and angle we calculate how much we need to remove
- * from the shape radius to move the point inwards by that x.
- *
- * We average the left and right distances to get the maximum shape radius that can fit in the box
- * along with labels.
- *
- * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
- * on each side, removing that from the size, halving it and adding the left x protrusion width.
- *
- * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
- * and position it in the most space efficient manner
- *
- * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
- */
-
-
- // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
- // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
- var largestPossibleRadius = min([(this.height / 2 - this.pointLabelFontSize - 5), this.width / 2]),
- pointPosition,
- i,
- textWidth,
- halfTextWidth,
- furthestRight = this.width,
- furthestRightIndex,
- furthestRightAngle,
- furthestLeft = 0,
- furthestLeftIndex,
- furthestLeftAngle,
- xProtrusionLeft,
- xProtrusionRight,
- radiusReductionRight,
- radiusReductionLeft,
- maxWidthRadius;
- this.ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily);
- for(i = 0; i < this.valuesCount; i++) {
- // 5px to space the text slightly out - similar to what we do in the draw function.
- pointPosition = this.getPointPosition(i, largestPossibleRadius);
- textWidth = this.ctx.measureText(template(this.templateString, {
- value: this.labels[i]
- })).width + 5;
- if(i === 0 || i === this.valuesCount / 2) {
- // If we're at index zero, or exactly the middle, we're at exactly the top/bottom
- // of the radar chart, so text will be aligned centrally, so we'll half it and compare
- // w/left and right text sizes
- halfTextWidth = textWidth / 2;
- if(pointPosition.x + halfTextWidth > furthestRight) {
- furthestRight = pointPosition.x + halfTextWidth;
- furthestRightIndex = i;
- }
- if(pointPosition.x - halfTextWidth < furthestLeft) {
- furthestLeft = pointPosition.x - halfTextWidth;
- furthestLeftIndex = i;
- }
- } else if(i < this.valuesCount / 2) {
- // Less than half the values means we'll left align the text
- if(pointPosition.x + textWidth > furthestRight) {
- furthestRight = pointPosition.x + textWidth;
- furthestRightIndex = i;
- }
- } else if(i > this.valuesCount / 2) {
- // More than half the values means we'll right align the text
- if(pointPosition.x - textWidth < furthestLeft) {
- furthestLeft = pointPosition.x - textWidth;
- furthestLeftIndex = i;
- }
- }
- }
-
- xProtrusionLeft = furthestLeft;
-
- xProtrusionRight = Math.ceil(furthestRight - this.width);
-
- furthestRightAngle = this.getIndexAngle(furthestRightIndex);
-
- furthestLeftAngle = this.getIndexAngle(furthestLeftIndex);
-
- radiusReductionRight = xProtrusionRight / Math.sin(furthestRightAngle + Math.PI / 2);
-
- radiusReductionLeft = xProtrusionLeft / Math.sin(furthestLeftAngle + Math.PI / 2);
-
- // Ensure we actually need to reduce the size of the chart
- radiusReductionRight = (isNumber(radiusReductionRight)) ? radiusReductionRight : 0;
- radiusReductionLeft = (isNumber(radiusReductionLeft)) ? radiusReductionLeft : 0;
-
- this.drawingArea = largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2;
-
- //this.drawingArea = min([maxWidthRadius, (this.height - (2 * (this.pointLabelFontSize + 5)))/2])
- this.setCenterPoint(radiusReductionLeft, radiusReductionRight);
-
- },
- setCenterPoint: function(leftMovement, rightMovement) {
-
- var maxRight = this.width - rightMovement - this.drawingArea,
- maxLeft = leftMovement + this.drawingArea;
-
- this.xCenter = (maxLeft + maxRight) / 2;
- // Always vertically in the centre as the text height doesn't change
- this.yCenter = (this.height / 2);
- },
-
- getIndexAngle: function(index) {
- var angleMultiplier = (Math.PI * 2) / this.valuesCount;
- // Start from the top instead of right, so remove a quarter of the circle
-
- return index * angleMultiplier - (Math.PI / 2);
- },
- getPointPosition: function(index, distanceFromCenter) {
- var thisAngle = this.getIndexAngle(index);
- return {
- x: (Math.cos(thisAngle) * distanceFromCenter) + this.xCenter,
- y: (Math.sin(thisAngle) * distanceFromCenter) + this.yCenter
- };
- },
- draw: function() {
- if(this.display) {
- var ctx = this.ctx;
- each(this.yLabels, function(label, index) {
- // Don't draw a centre value
- if(index > 0) {
- var yCenterOffset = index * (this.drawingArea / this.steps),
- yHeight = this.yCenter - yCenterOffset,
- pointPosition;
-
- // Draw circular lines around the scale
- if(this.lineWidth > 0) {
- ctx.strokeStyle = this.lineColor;
- ctx.lineWidth = this.lineWidth;
-
- if(this.lineArc) {
- ctx.beginPath();
- ctx.arc(this.xCenter, this.yCenter, yCenterOffset, 0, Math.PI * 2);
- ctx.closePath();
- ctx.stroke();
- } else {
- ctx.beginPath();
- for(var i = 0; i < this.valuesCount; i++) {
- pointPosition = this.getPointPosition(i, this.calculateCenterOffset(this.min + (index * this.stepValue)));
- if(i === 0) {
- ctx.moveTo(pointPosition.x, pointPosition.y);
- } else {
- ctx.lineTo(pointPosition.x, pointPosition.y);
- }
- }
- ctx.closePath();
- ctx.stroke();
- }
- }
- if(this.showLabels) {
- ctx.font = fontString(this.fontSize, this.fontStyle, this.fontFamily);
- if(this.showLabelBackdrop) {
- var labelWidth = ctx.measureText(label).width;
- ctx.fillStyle = this.backdropColor;
- ctx.fillRect(
- this.xCenter - labelWidth / 2 - this.backdropPaddingX,
- yHeight - this.fontSize / 2 - this.backdropPaddingY,
- labelWidth + this.backdropPaddingX * 2,
- this.fontSize + this.backdropPaddingY * 2
- );
- }
- ctx.textAlign = 'center';
- ctx.textBaseline = "middle";
- ctx.fillStyle = this.fontColor;
- ctx.fillText(label, this.xCenter, yHeight);
- }
- }
- }, this);
-
- if(!this.lineArc) {
- ctx.lineWidth = this.angleLineWidth;
- ctx.strokeStyle = this.angleLineColor;
- for(var i = this.valuesCount - 1; i >= 0; i--) {
- if(this.angleLineWidth > 0) {
- var outerPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max));
- ctx.beginPath();
- ctx.moveTo(this.xCenter, this.yCenter);
- ctx.lineTo(outerPosition.x, outerPosition.y);
- ctx.stroke();
- ctx.closePath();
- }
- // Extra 3px out for some label spacing
- var pointLabelPosition = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5);
- ctx.font = fontString(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily);
- ctx.fillStyle = this.pointLabelFontColor;
-
- var labelsCount = this.labels.length,
- halfLabelsCount = this.labels.length / 2,
- quarterLabelsCount = halfLabelsCount / 2,
- upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount),
- exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount);
- if(i === 0) {
- ctx.textAlign = 'center';
- } else if(i === halfLabelsCount) {
- ctx.textAlign = 'center';
- } else if(i < halfLabelsCount) {
- ctx.textAlign = 'left';
- } else {
- ctx.textAlign = 'right';
- }
-
- // Set the correct text baseline based on outer positioning
- if(exactQuarter) {
- ctx.textBaseline = 'middle';
- } else if(upperHalf) {
- ctx.textBaseline = 'bottom';
- } else {
- ctx.textBaseline = 'top';
- }
-
- ctx.fillText(this.labels[i], pointLabelPosition.x, pointLabelPosition.y);
- }
- }
- }
- }
- });
-
- // Attach global event to resize each chart instance when the browser resizes
- helpers.addEvent(window, "resize", (function() {
- // Basic debounce of resize function so it doesn't hurt performance when resizing browser.
- var timeout;
- return function() {
- clearTimeout(timeout);
- timeout = setTimeout(function() {
- each(Chart.instances, function(instance) {
- // If the responsive flag is set in the chart instance config
- // Cascade the resize event down to the chart.
- if(instance.options.responsive) {
- instance.resize(instance.render, true);
- }
- });
- }, 50);
- };
- })());
-
-
- if(amd) {
- define(function() {
- return Chart;
- });
- } else if(typeof module === 'object' && module.exports) {
- module.exports = Chart;
- }
-
- root.Chart = Chart;
-
- /// ----- ZUI change begin -----
- /// Use jquery object to create Chart object
- $.fn.chart = function() {
- var charts = [];
- this.each(function() {
- charts.push(new Chart(this.getContext("2d")));
- });
- return charts.length === 1 ? charts[0] : charts;
- }
-
- /// ----- ZUI change end -----
-
- /// ----- ZUI change begin -----
- /// Remove unused code
- // Chart.noConflict = function() // old code begin
- // {
- // root.Chart = previous;
- // return Chart;
- // }; // old code end
- /// ----- ZUI change end -----
-
- /// ----- ZUI change begin -----
- /// Add jquery object to namespace
-
- /// }).call(this); // Old code
-}).call(this, jQuery);
-
-/// ----- ZUI change end -----
-
-
-/* ========================================================================
- * Chart.js: Chart.line.js [Version: 1.0.2]
- * http://chartjs.org/
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2015 Nick Downie, Released under the MIT license
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
- * ======================================================================== */
-
-
-/// ----- ZUI change begin -----
-/// Add jquery object to namespace
-
-/// (function(){ // Old code
-(function($) {
-
- /// ----- ZUI change end -----
- "use strict";
-
- /// ----- ZUI change begin -----
- /// Change root to zui shared object
- ///
- /// var root = this, // old code
- var root = $ && $.zui ? $.zui : this,
- /// ----- ZUI change end -----
- Chart = root.Chart,
- helpers = Chart.helpers;
-
- var defaultConfig = {
-
- ///Boolean - Whether grid lines are shown across the chart
- scaleShowGridLines: true,
-
- //String - Colour of the grid lines
- scaleGridLineColor: "rgba(0,0,0,.05)",
-
- //Number - Width of the grid lines
- scaleGridLineWidth: 1,
-
- //Boolean - Whether to show horizontal lines (except X axis)
- scaleShowHorizontalLines: true,
-
- /// ZUI change end
- //Boolean - Whether to show beyond lines
- scaleShowBeyondLine: true,
- /// ZUI change end
- ///
- //Boolean - Whether to show vertical lines (except Y axis)
- scaleShowVerticalLines: true,
-
- //Boolean - Whether the line is curved between points
- bezierCurve: true,
-
- //Number - Tension of the bezier curve between points
- bezierCurveTension: 0.4,
-
- //Boolean - Whether to show a dot for each point
- pointDot: true,
-
- //Number - Radius of each point dot in pixels
- pointDotRadius: 4,
-
- //Number - Pixel width of point dot stroke
- pointDotStrokeWidth: 1,
-
- //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
- pointHitDetectionRadius: 20,
-
- //Boolean - Whether to show a stroke for datasets
- datasetStroke: true,
-
- //Number - Pixel width of dataset stroke
- datasetStrokeWidth: 2,
-
- //Boolean - Whether to fill the dataset with a colour
- datasetFill: true,
-
- //String - A legend template
- legendTemplate: "-legend\"><% for (var i=0; i- \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
<%}%> "
-
- };
-
-
- Chart.Type.extend({
- name: "Line",
- defaults: defaultConfig,
-
- initialize: function(data) {
- //Declare the extension of the default point, to cater for the options passed in to the constructor
- this.PointClass = Chart.Point.extend({
- strokeWidth: this.options.pointDotStrokeWidth,
- radius: this.options.pointDotRadius,
- display: this.options.pointDot,
- hitDetectionRadius: this.options.pointHitDetectionRadius,
- ctx: this.chart.ctx,
- inRange: function(mouseX) {
- return(Math.pow(mouseX - this.x, 2) < Math.pow(this.radius + this.hitDetectionRadius, 2));
- }
- });
-
- this.datasets = [];
-
- //Set up tooltip events on the chart
- if(this.options.showTooltips) {
- helpers.bindEvents(this, this.options.tooltipEvents, function(evt) {
- var activePoints = (evt.type !== 'mouseout') ? this.getPointsAtEvent(evt) : [];
- this.eachPoints(function(point) {
- point.restore(['fillColor', 'strokeColor']);
- });
- helpers.each(activePoints, function(activePoint) {
- activePoint.fillColor = activePoint.highlightFill;
- activePoint.strokeColor = activePoint.highlightStroke;
- });
- this.showTooltip(activePoints);
- });
- }
-
- //Iterate through each of the datasets, and build this into a property of the chart
- helpers.each(data.datasets, function(dataset) {
- /// ----- ZUI change begin -----
- // add color theme
- if($.zui && $.zui.Color && $.zui.Color.get) {
- var accentColor = $.zui.Color.get(dataset.color);
- var accentColorValue = accentColor.toCssStr();
-
- if(!dataset.fillColor) dataset.fillColor = accentColor.clone().fade(20).toCssStr();
- if(!dataset.strokeColor) dataset.strokeColor = accentColorValue;
- if(!dataset.pointColor) dataset.pointColor = accentColorValue;
- if(!dataset.pointStrokeColor) dataset.pointStrokeColor = '#fff';
- if(!dataset.pointHighlightFill) dataset.pointHighlightFill = '#fff';
- if(!dataset.pointHighlightStroke) dataset.pointHighlightStroke = accentColorValue;
- }
- /// ----- ZUI change begin -----
-
- var datasetObject = {
- label: dataset.label || null,
- fillColor: dataset.fillColor,
- strokeColor: dataset.strokeColor,
- pointColor: dataset.pointColor,
- pointStrokeColor: dataset.pointStrokeColor,
- /// ZUI change begin
- showTooltips: dataset.showTooltips !== false,
- /// ZUI change end
- points: []
- };
-
- this.datasets.push(datasetObject);
-
-
- helpers.each(dataset.data, function(dataPoint, index) {
- //Add a new point for each piece of data, passing any required data to draw.
- datasetObject.points.push(new this.PointClass({
- value: dataPoint,
- label: data.labels[index],
- datasetLabel: dataset.label,
- strokeColor: dataset.pointStrokeColor,
- fillColor: dataset.pointColor,
- highlightFill: dataset.pointHighlightFill || dataset.pointColor,
- highlightStroke: dataset.pointHighlightStroke || dataset.pointStrokeColor
- }));
- }, this);
-
- this.buildScale(data.labels);
-
-
- this.eachPoints(function(point, index) {
- helpers.extend(point, {
- x: this.scale.calculateX(index),
- y: this.scale.endPoint
- });
- point.save();
- }, this);
-
- }, this);
-
-
- this.render();
- },
- update: function() {
- this.scale.update();
- // Reset any highlight colours before updating.
- helpers.each(this.activeElements, function(activeElement) {
- activeElement.restore(['fillColor', 'strokeColor']);
- });
- this.eachPoints(function(point) {
- point.save();
- });
- this.render();
- },
- eachPoints: function(callback) {
- helpers.each(this.datasets, function(dataset) {
- helpers.each(dataset.points, callback, this);
- }, this);
- },
- getPointsAtEvent: function(e) {
- var pointsArray = [],
- eventPosition = helpers.getRelativePosition(e);
- helpers.each(this.datasets, function(dataset) {
- helpers.each(dataset.points, function(point) {
- if(point.inRange(eventPosition.x, eventPosition.y)) pointsArray.push(point);
- });
- }, this);
- return pointsArray;
- },
- buildScale: function(labels) {
- var self = this;
-
- var dataTotal = function() {
- var values = [];
- self.eachPoints(function(point) {
- values.push(point.value);
- });
-
- return values;
- };
-
- var scaleOptions = {
- templateString: this.options.scaleLabel,
- height: this.chart.height,
- width: this.chart.width,
- ctx: this.chart.ctx,
- textColor: this.options.scaleFontColor,
- fontSize: this.options.scaleFontSize,
- fontStyle: this.options.scaleFontStyle,
- fontFamily: this.options.scaleFontFamily,
- valuesCount: labels.length,
- beginAtZero: this.options.scaleBeginAtZero,
- integersOnly: this.options.scaleIntegersOnly,
- calculateYRange: function(currentHeight) {
- var updatedRanges = helpers.calculateScaleRange(
- dataTotal(),
- currentHeight,
- this.fontSize,
- this.beginAtZero,
- this.integersOnly
- );
- helpers.extend(this, updatedRanges);
- },
- xLabels: labels,
- font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily),
- lineWidth: this.options.scaleLineWidth,
- lineColor: this.options.scaleLineColor,
- showHorizontalLines: this.options.scaleShowHorizontalLines,
- showVerticalLines: this.options.scaleShowVerticalLines,
- /// ZUI change begin
- showBeyondLine: this.options.scaleShowBeyondLine,
- /// ZUI change end
- gridLineWidth: (this.options.scaleShowGridLines) ? this.options.scaleGridLineWidth : 0,
- gridLineColor: (this.options.scaleShowGridLines) ? this.options.scaleGridLineColor : "rgba(0,0,0,0)",
- padding: (this.options.showScale) ? 0 : this.options.pointDotRadius + this.options.pointDotStrokeWidth,
- showLabels: this.options.scaleShowLabels,
- display: this.options.showScale
- };
-
- if(this.options.scaleOverride) {
- helpers.extend(scaleOptions, {
- calculateYRange: helpers.noop,
- steps: this.options.scaleSteps,
- stepValue: this.options.scaleStepWidth,
- min: this.options.scaleStartValue,
- max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth)
- });
- }
-
-
- this.scale = new Chart.Scale(scaleOptions);
- },
- addData: function(valuesArray, label) {
- //Map the values array for each of the datasets
-
- helpers.each(valuesArray,function(value,datasetIndex){
- //Add a new point for each piece of data, passing any required data to draw.
- this.datasets[datasetIndex].points.push(new this.PointClass({
- value : value,
- label : label,
- datasetLabel: this.datasets[datasetIndex].label,
- x: this.scale.calculateX(this.scale.valuesCount+1),
- y: this.scale.endPoint,
- strokeColor : this.datasets[datasetIndex].pointStrokeColor,
- fillColor : this.datasets[datasetIndex].pointColor
- }));
- },this);
-
- this.scale.addXLabel(label);
- //Then re-render the chart.
- this.update();
- },
- removeData: function() {
- this.scale.removeXLabel();
- //Then re-render the chart.
- helpers.each(this.datasets, function(dataset) {
- dataset.points.shift();
- }, this);
- this.update();
- },
- reflow: function() {
- var newScaleProps = helpers.extend({
- height: this.chart.height,
- width: this.chart.width
- });
- this.scale.update(newScaleProps);
- },
- draw: function(ease) {
- var easingDecimal = ease || 1;
- this.clear();
-
- var ctx = this.chart.ctx;
-
- // Some helper methods for getting the next/prev points
- var hasValue = function(item) {
- return item.value !== null;
- },
- nextPoint = function(point, collection, index) {
- return helpers.findNextWhere(collection, hasValue, index) || point;
- },
- previousPoint = function(point, collection, index) {
- return helpers.findPreviousWhere(collection, hasValue, index) || point;
- };
-
- this.scale.draw(easingDecimal);
-
-
- helpers.each(this.datasets, function(dataset) {
- var pointsWithValues = helpers.where(dataset.points, hasValue);
-
- //Transition each point first so that the line and point drawing isn't out of sync
- //We can use this extra loop to calculate the control points of this dataset also in this loop
-
- helpers.each(dataset.points, function(point, index) {
- if(point.hasValue()) {
- point.transition({
- y: this.scale.calculateY(point.value),
- x: this.scale.calculateX(index)
- }, easingDecimal);
- }
- }, this);
-
-
- // Control points need to be calculated in a seperate loop, because we need to know the current x/y of the point
- // This would cause issues when there is no animation, because the y of the next point would be 0, so beziers would be skewed
- if(this.options.bezierCurve) {
- helpers.each(pointsWithValues, function(point, index) {
- var tension = (index > 0 && index < pointsWithValues.length - 1) ? this.options.bezierCurveTension : 0;
- point.controlPoints = helpers.splineCurve(
- previousPoint(point, pointsWithValues, index),
- point,
- nextPoint(point, pointsWithValues, index),
- tension
- );
-
- // Prevent the bezier going outside of the bounds of the graph
-
- // Cap puter bezier handles to the upper/lower scale bounds
- if(point.controlPoints.outer.y > this.scale.endPoint) {
- point.controlPoints.outer.y = this.scale.endPoint;
- } else if(point.controlPoints.outer.y < this.scale.startPoint) {
- point.controlPoints.outer.y = this.scale.startPoint;
- }
-
- // Cap inner bezier handles to the upper/lower scale bounds
- if(point.controlPoints.inner.y > this.scale.endPoint) {
- point.controlPoints.inner.y = this.scale.endPoint;
- } else if(point.controlPoints.inner.y < this.scale.startPoint) {
- point.controlPoints.inner.y = this.scale.startPoint;
- }
- }, this);
- }
-
-
- //Draw the line between all the points
- ctx.lineWidth = this.options.datasetStrokeWidth;
- ctx.strokeStyle = dataset.strokeColor;
- ctx.beginPath();
-
- helpers.each(pointsWithValues, function(point, index) {
- if(index === 0) {
- ctx.moveTo(point.x, point.y);
- } else {
- if(this.options.bezierCurve) {
- var previous = previousPoint(point, pointsWithValues, index);
-
- ctx.bezierCurveTo(
- previous.controlPoints.outer.x,
- previous.controlPoints.outer.y,
- point.controlPoints.inner.x,
- point.controlPoints.inner.y,
- point.x,
- point.y
- );
- } else {
- ctx.lineTo(point.x, point.y);
- }
- }
- }, this);
-
- ctx.stroke();
-
- if(this.options.datasetFill && pointsWithValues.length > 0) {
- //Round off the line by going to the base of the chart, back to the start, then fill.
- ctx.lineTo(pointsWithValues[pointsWithValues.length - 1].x, this.scale.endPoint);
- ctx.lineTo(pointsWithValues[0].x, this.scale.endPoint);
- ctx.fillStyle = dataset.fillColor;
- ctx.closePath();
- ctx.fill();
- }
-
- //Now draw the points over the line
- //A little inefficient double looping, but better than the line
- //lagging behind the point positions
- helpers.each(pointsWithValues, function(point) {
- point.draw();
- });
- }, this);
- }
- });
-
- /// ----- ZUI change begin -----
- /// Use jquery object to create Chart object
- $.fn.lineChart = function(data, options) {
- var lineCharts = [];
- this.each(function() {
- var $this = $(this);
- lineCharts.push(new Chart(this.getContext("2d")).Line(data, $.extend($this.data(), options)));
- });
- return lineCharts.length === 1 ? lineCharts[0] : lineCharts;
- }
-
- /// ----- ZUI change end -----
-
- /// ----- ZUI change begin -----
- /// Add jquery object to namespace
-
- /// }).call(this); // Old code
-}).call(this, jQuery);
-
-/// ----- ZUI change end -----
-
-
-/* ========================================================================
- * Chart.js: Chart.Doughnut.js [Version: 1.0.2]
- * http://chartjs.org/
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2015 Nick Downie, Released under the MIT license
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
- * ======================================================================== */
-
-/// ----- ZUI change begin -----
-/// Add jquery object to namespace
-
-/// (function(){ // Old code
-(function($) {
-
- /// ----- ZUI change end -----
- "use strict";
-
- /// ----- ZUI change begin -----
- /// Change root to zui shared object
- ///
- /// var root = this, // old code
- var root = $ && $.zui ? $.zui : this,
- /// ----- ZUI change end -----
- Chart = root.Chart,
- //Cache a local reference to Chart.helpers
- helpers = Chart.helpers;
-
- var defaultConfig = {
- //Boolean - Whether we should show a stroke on each segment
- segmentShowStroke: true,
-
- //String - The colour of each segment stroke
- segmentStrokeColor: "#fff",
-
- //Number - The width of each segment stroke
- /// ZUI change begin
- /// segmentStrokeWidth: 2, // old code
- segmentStrokeWidth: 1,
- /// ZUI change end
-
- //The percentage of the chart that we cut out of the middle.
- percentageInnerCutout: 50,
-
- /// ZUI change begin
- // Boolean - Whether to show labels on the scale
- scaleShowLabels: false,
-
- // Interpolated JS string - can access value
- scaleLabel: "<%=value%>",
-
- // String - Scale label position
- scaleLabelPlacement: 'auto',
-
- /// Number - Amount of animation steps // old code
- /// animationSteps: 100, // old code
- animationSteps: 60,
- /// ZUI change end
-
- //String - Animation easing effect
- animationEasing: "easeOutBounce",
-
- //Boolean - Whether we animate the rotation of the Doughnut
- animateRotate: true,
-
- //Boolean - Whether we animate scaling the Doughnut from the centre
- animateScale: false,
-
- //String - A legend template
- legendTemplate: "-legend\"><% for (var i=0; i- \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
<%}%> "
-
- };
-
-
- Chart.Type.extend({
- //Passing in a name registers this chart in the Chart namespace
- name: "Doughnut",
- //Providing a defaults will also register the deafults in the chart namespace
- defaults: defaultConfig,
- //Initialize is fired when the chart is initialized - Data is passed in as a parameter
- //Config is automatically merged by the core of Chart.js, and is available at this.options
- initialize: function(data) {
-
- //Declare segments as a static property to prevent inheriting across the Chart type prototype
- this.segments = [];
- this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2;
-
- this.SegmentArc = Chart.Arc.extend({
- ctx: this.chart.ctx,
- x: this.chart.width / 2,
- y: this.chart.height / 2
- });
-
- //Set up tooltip events on the chart
- if(this.options.showTooltips) {
- helpers.bindEvents(this, this.options.tooltipEvents, function(evt) {
- var activeSegments = (evt.type !== 'mouseout') ? this.getSegmentsAtEvent(evt) : [];
-
- helpers.each(this.segments, function(segment) {
- segment.restore(["fillColor"]);
- });
- helpers.each(activeSegments, function(activeSegment) {
- activeSegment.fillColor = activeSegment.highlightColor;
- });
- this.showTooltip(activeSegments);
- });
- }
- this.calculateTotal(data);
-
- helpers.each(data, function(datapoint, index) {
- this.addData(datapoint, index, true);
- }, this);
-
- this.render();
- },
- getSegmentsAtEvent: function(e) {
- var segmentsArray = [];
-
- var location = helpers.getRelativePosition(e);
-
- helpers.each(this.segments, function(segment) {
- if(segment.inRange(location.x, location.y)) segmentsArray.push(segment);
- }, this);
- return segmentsArray;
- },
- addData: function(segment, atIndex, silent) {
- /// ----- ZUI change begin -----
- /// Init segment color
- if($.zui && $.zui.Color && $.zui.Color.get) {
- var color = new $.zui.Color.get(segment.color);
- segment.color = color.toCssStr();
- if(!segment.highlight) segment.highlight = color.lighten(5).toCssStr();
- }
- /// ----- ZUI change end -----
- var index = atIndex || this.segments.length;
- this.segments.splice(index, 0, new this.SegmentArc({
- id: typeof segment.id === 'undefined' ? index : segment.id,
- value: segment.value,
- outerRadius: (this.options.animateScale) ? 0 : this.outerRadius,
- innerRadius: (this.options.animateScale) ? 0 : (this.outerRadius / 100) * this.options.percentageInnerCutout,
- fillColor: segment.color,
- highlightColor: segment.highlight || segment.color,
- showStroke: this.options.segmentShowStroke,
- strokeWidth: this.options.segmentStrokeWidth,
- strokeColor: this.options.segmentStrokeColor,
- startAngle: Math.PI * 1.5,
- circumference: (this.options.animateRotate) ? 0 : this.calculateCircumference(segment.value),
- /// ----- ZUI change begin -----
- showLabel: segment.showLabel !== false,
- circleBeginEnd: segment.circleBeginEnd,
- /// ----- ZUI change end -----
- label: segment.label
- }));
- if(!silent) {
- this.reflow();
- this.update();
- }
- },
- calculateCircumference: function(value) {
- return(Math.PI * 2) * (Math.abs(value) / this.total);
- },
- calculateTotal: function(data) {
- this.total = 0;
- helpers.each(data, function(segment) {
- this.total += Math.abs(segment.value);
- }, this);
- },
- update: function() {
- this.calculateTotal(this.segments);
-
- // Reset any highlight colours before updating.
- helpers.each(this.activeElements, function(activeElement) {
- activeElement.restore(['fillColor']);
- });
-
- helpers.each(this.segments, function(segment) {
- segment.save();
- });
- this.render();
- },
-
- removeData: function(atIndex) {
- var indexToDelete = (helpers.isNumber(atIndex)) ? atIndex : this.segments.length - 1;
- this.segments.splice(indexToDelete, 1);
- this.reflow();
- this.update();
- },
-
- reflow: function() {
- helpers.extend(this.SegmentArc.prototype, {
- x: this.chart.width / 2,
- y: this.chart.height / 2
- });
- this.outerRadius = (helpers.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2;
- helpers.each(this.segments, function(segment) {
- segment.update({
- outerRadius: this.outerRadius,
- innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout
- });
- }, this);
- },
- /// ZUI change begin
- drawLabel: function(segment, easeDecimal, labelPosMap) {
- var options = this.options;
- var middleAngle = (segment.endAngle + segment.startAngle) / 2;
- var placement = options.scaleLabelPlacement;
- if(placement !== 'inside' && placement !== 'outside') {
- if((this.chart.width - this.chart.height) > 50) {
- if(segment.circumference < (Math.PI / 18)) {
- placement = 'outside';
- }
- }
- }
-
- var x = Math.cos(middleAngle) * segment.outerRadius,
- y = Math.sin(middleAngle) * segment.outerRadius,
- text = helpers.template(options.scaleLabel, {
- value: typeof easeDecimal === 'undefined' ? segment.value : Math.round(easeDecimal * segment.value),
- label: segment.label
- });
-
- var ctx = this.chart.ctx;
- ctx.font = helpers.fontString(options.scaleFontSize, options.scaleFontStyle, options.scaleFontFamily);
- ctx.textBaseline = "middle";
- ctx.textAlign = "center";
-
- var textWidth = ctx.measureText(text).width;
- var chartWidthHalf = this.chart.width / 2;
- var chartHeightHalf = this.chart.height / 2;
-
- if(placement === 'outside') { // outside
- var isRight = x >= 0;
- var lineX = x + chartWidthHalf;
- var lineY = y + chartHeightHalf;
- ctx.textAlign = isRight ? 'left' : 'right';
- ctx.measureText(text).width;
- if(isRight) {
- x = Math.max(chartWidthHalf + segment.outerRadius + 10, x + 30 + chartWidthHalf);
- } else {
- x = Math.min(chartWidthHalf - segment.outerRadius - 10, x - 30 + chartWidthHalf);
- }
-
- var textHeight = options.scaleFontSize * (options.scaleLineHeight || 1);
- var labelPos = Math.round((y * 0.8 + chartHeightHalf) / textHeight) + 1;
- var maxPos = Math.floor(this.chart.width / textHeight) + 1;
- var labelPosDirection = isRight ? 1 : (-1);
- if(labelPosMap[labelPos*labelPosDirection]) {
- if(labelPos > 1) labelPos--;
- else labelPos++;
- }
- // while(labelPosMap[labelPos*labelPosDirection] && labelPos < maxPos) labelPos++;
-
- if(labelPosMap[labelPos*labelPosDirection]) return;
- y = (labelPos - 1) * textHeight + options.scaleFontSize / 2;
- labelPosMap[labelPos*labelPosDirection] = true;
-
- ctx.beginPath();
- ctx.moveTo(lineX, lineY);
- ctx.lineTo(x, y);
- x = isRight ? (x + 5) : (x - 5);
- ctx.lineTo(x, y);
- ctx.strokeStyle = ($.zui && $.zui.Color) ? (new $.zui.Color(segment.fillColor).fade(40).toCssStr()) : segment.fillColor;
- ctx.strokeWidth = options.scaleLineWidth;
- ctx.stroke();
- ctx.fillStyle = segment.fillColor;
- } else { // inside
- x = x * 0.7 + chartWidthHalf;
- y = y * 0.7 + chartHeightHalf;
- ctx.fillStyle = ($.zui && $.zui.Color) ? (new $.zui.Color(segment.fillColor).contrast().toCssStr()) : '#fff';
- }
- ctx.fillText(text, x, y);
- },
- // ZUI change end
- draw: function(easeDecimal) {
- var animDecimal = (easeDecimal) ? easeDecimal : 1;
- this.clear();
- // ZUI change begin
- var labelPositionMap;
- // ZUI change end
- helpers.each(this.segments, function(segment, index) {
- segment.transition({
- circumference: this.calculateCircumference(segment.value),
- outerRadius: this.outerRadius,
- innerRadius: (this.outerRadius / 100) * this.options.percentageInnerCutout
- }, animDecimal);
-
- segment.endAngle = segment.startAngle + segment.circumference;
-
- // ZUI change begin
- if (!this.options.reverseDrawOrder) {
- // ZUI change end
- // ZUI change begin
- segment.draw();
- // ZUI change end
- }
- // ZUI change end
-
- if(index === 0) {
- segment.startAngle = Math.PI * 1.5;
- }
- //Check to see if it's the last segment, if not get the next and update the start angle
- if(index < this.segments.length - 1) {
- this.segments[index + 1].startAngle = segment.endAngle;
- }
- }, this);
-
- // ZUI change begin
- if (this.options.reverseDrawOrder) {
- helpers.each(this.segments.slice().reverse(), function(segment, index) {
- segment.draw();
- }, this);
- }
- /// ZUI change end
-
- /// ZUI change begin
- if(this.options.scaleShowLabels) {
- var segmentsArray = this.segments.slice().sort(function(a,b){return b.value - a.value;});
- var labelPositionMap = {};
- helpers.each(segmentsArray, function(segment, index) {
- if(segment.showLabel) this.drawLabel(segment, easeDecimal, labelPositionMap);
- }, this);
- }
- /// ZUI change end
- }
- });
-
- Chart.types.Doughnut.extend({
- name: "Pie",
- defaults: helpers.merge(defaultConfig, {
- percentageInnerCutout: 0
- })
- });
-
- /// ----- ZUI change begin -----
- /// Use jquery object to create Chart object
- $.fn.pieChart = function(data, options) {
- var pieCharts = [];
- this.each(function() {
- var $this = $(this);
- pieCharts.push(new Chart(this.getContext("2d")).Pie(data, $.extend($this.data(), options)));
- });
- return pieCharts.length === 1 ? pieCharts[0] : pieCharts;
- }
-
- $.fn.doughnutChart = function(data, options) {
- var doughnutCharts = [];
- this.each(function() {
- var $this = $(this);
- doughnutCharts.push(new Chart(this.getContext("2d")).Doughnut(data, $.extend($this.data(), options)));
- });
- return doughnutCharts.length === 1 ? doughnutCharts[0] : doughnutCharts;
- }
-
- /// ----- ZUI change end -----
-
- /// ----- ZUI change begin -----
- /// Add jquery object to namespace
-
- /// }).call(this); // Old code
-}).call(this, jQuery);
-
-/// ----- ZUI change end -----
-
-
-/* ========================================================================
- * Chart.js: Chart.Bar.js [Version: 1.0.2]
- * http://chartjs.org/
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2015 Nick Downie, Released under the MIT license
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
- * ======================================================================== */
-
-
-/// ----- ZUI change begin -----
-/// Add jquery object to namespace
-
-/// (function(){ // Old code
-(function($) {
-
- /// ----- ZUI change end -----
- "use strict";
-
- /// ----- ZUI change begin -----
- /// Change root to zui shared object
- ///
- /// var root = this, // old code
- var root = $ && $.zui ? $.zui : this,
- /// ----- ZUI change end -----
- Chart = root.Chart,
- helpers = Chart.helpers;
-
-
- var defaultConfig = {
- //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
- scaleBeginAtZero: true,
-
- //Boolean - Whether grid lines are shown across the chart
- scaleShowGridLines: true,
-
- //String - Colour of the grid lines
- scaleGridLineColor: "rgba(0,0,0,.05)",
-
- //Number - Width of the grid lines
- scaleGridLineWidth: 1,
-
- //Boolean - Whether to show horizontal lines (except X axis)
- scaleShowHorizontalLines: true,
-
- //Boolean - Whether to show vertical lines (except Y axis)
- scaleShowVerticalLines: true,
-
- /// ZUI change begin
- //Boolean - Whether to show beyond lines
- scaleShowBeyondLine: true,
- /// ZUI change end
- ///
- //Boolean - If there is a stroke on each bar
- barShowStroke: true,
-
- //Number - Pixel width of the bar stroke
- /// ZUI change begin
- /// barStrokeWidth: 2,
- barStrokeWidth: 1,
-
- // String - Sacle value labels placement
- scaleValuePlacement: 'auto', // none, auto, outside, inside-top, inside-middle, inside-bottom
- /// ZUI change end
-
- //Number - Spacing between each of the X value sets
- barValueSpacing: 5,
-
- //Number - Spacing between data sets within X values
- barDatasetSpacing: 1,
-
- //String - A legend template
- legendTemplate: "-legend\"><% for (var i=0; i- \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
<%}%> "
- };
-
-
- Chart.Type.extend({
- name: "Bar",
- defaults: defaultConfig,
- initialize: function(data) {
-
- //Expose options as a scope variable here so we can access it in the ScaleClass
- var options = this.options;
-
- this.ScaleClass = Chart.Scale.extend({
- offsetGridLines: true,
- calculateBarX: function(datasetCount, datasetIndex, barIndex) {
- //Reusable method for calculating the xPosition of a given bar based on datasetIndex & width of the bar
- var xWidth = this.calculateBaseWidth(),
- xAbsolute = this.calculateX(barIndex) - (xWidth / 2),
- barWidth = this.calculateBarWidth(datasetCount);
-
- return xAbsolute + (barWidth * datasetIndex) + (datasetIndex * options.barDatasetSpacing) + barWidth / 2;
- },
- calculateBaseWidth: function() {
- return(this.calculateX(1) - this.calculateX(0)) - (2 * options.barValueSpacing);
- },
- calculateBarWidth: function(datasetCount) {
- //The padding between datasets is to the right of each bar, providing that there are more than 1 dataset
- var baseWidth = this.calculateBaseWidth() - ((datasetCount - 1) * options.barDatasetSpacing);
-
- return(baseWidth / datasetCount);
- }
- });
-
- this.datasets = [];
-
- //Set up tooltip events on the chart
- if(this.options.showTooltips) {
- helpers.bindEvents(this, this.options.tooltipEvents, function(evt) {
- var activeBars = (evt.type !== 'mouseout') ? this.getBarsAtEvent(evt) : [];
-
- this.eachBars(function(bar) {
- bar.restore(['fillColor', 'strokeColor']);
- });
- helpers.each(activeBars, function(activeBar) {
- activeBar.fillColor = activeBar.highlightFill;
- activeBar.strokeColor = activeBar.highlightStroke;
- });
- this.showTooltip(activeBars);
- });
- }
-
- //Declare the extension of the default point, to cater for the options passed in to the constructor
- this.BarClass = Chart.Rectangle.extend({
- strokeWidth: this.options.barStrokeWidth,
- showStroke: this.options.barShowStroke,
- ctx: this.chart.ctx
- });
-
- //Iterate through each of the datasets, and build this into a property of the chart
- helpers.each(data.datasets, function(dataset, datasetIndex) {
- /// ----- ZUI change begin -----
- // add color theme
- if($.zui && $.zui.Color && $.zui.Color.get) {
- var accentColor = $.zui.Color.get(dataset.color);
- var accentColorValue = accentColor.toCssStr();
-
- if(!dataset.fillColor) dataset.fillColor = accentColor.clone().fade(50).toCssStr();
- if(!dataset.strokeColor) dataset.strokeColor = accentColorValue;
- }
- /// ----- ZUI change begin -----
-
- var datasetObject = {
- label: dataset.label || null,
- fillColor: dataset.fillColor,
- strokeColor: dataset.strokeColor,
- bars: []
- };
-
- this.datasets.push(datasetObject);
-
- helpers.each(dataset.data, function(dataPoint, index) {
- //Add a new point for each piece of data, passing any required data to draw.
- datasetObject.bars.push(new this.BarClass({
- value: dataPoint,
- label: data.labels[index],
- datasetLabel: dataset.label,
- strokeColor: dataset.strokeColor,
- fillColor: dataset.fillColor,
- highlightFill: dataset.highlightFill || dataset.fillColor,
- highlightStroke: dataset.highlightStroke || dataset.strokeColor
- }));
- }, this);
-
- }, this);
-
- this.buildScale(data.labels);
-
- this.BarClass.prototype.base = this.scale.endPoint;
-
- this.eachBars(function(bar, index, datasetIndex) {
- helpers.extend(bar, {
- width: this.scale.calculateBarWidth(this.datasets.length),
- x: this.scale.calculateBarX(this.datasets.length, datasetIndex, index),
- y: this.scale.endPoint
- });
- bar.save();
- }, this);
-
- this.render();
- },
- update: function() {
- this.scale.update();
- // Reset any highlight colours before updating.
- helpers.each(this.activeElements, function(activeElement) {
- activeElement.restore(['fillColor', 'strokeColor']);
- });
-
- this.eachBars(function(bar) {
- bar.save();
- });
- this.render();
- },
- eachBars: function(callback) {
- helpers.each(this.datasets, function(dataset, datasetIndex) {
- helpers.each(dataset.bars, callback, this, datasetIndex);
- }, this);
- },
- getBarsAtEvent: function(e) {
- var barsArray = [],
- eventPosition = helpers.getRelativePosition(e),
- datasetIterator = function(dataset) {
- barsArray.push(dataset.bars[barIndex]);
- },
- barIndex;
-
- for(var datasetIndex = 0; datasetIndex < this.datasets.length; datasetIndex++) {
- for(barIndex = 0; barIndex < this.datasets[datasetIndex].bars.length; barIndex++) {
- if(this.datasets[datasetIndex].bars[barIndex].inRange(eventPosition.x, eventPosition.y)) {
- helpers.each(this.datasets, datasetIterator);
- return barsArray;
- }
- }
- }
-
- return barsArray;
- },
- buildScale: function(labels) {
- var self = this;
-
- var dataTotal = function() {
- var values = [];
- self.eachBars(function(bar) {
- values.push(bar.value);
- });
- return values;
- };
-
- var scaleOptions = {
- templateString: this.options.scaleLabel,
- height: this.chart.height,
- width: this.chart.width,
- ctx: this.chart.ctx,
- textColor: this.options.scaleFontColor,
- fontSize: this.options.scaleFontSize,
- fontStyle: this.options.scaleFontStyle,
- fontFamily: this.options.scaleFontFamily,
- valuesCount: labels.length,
- beginAtZero: this.options.scaleBeginAtZero,
- integersOnly: this.options.scaleIntegersOnly,
- calculateYRange: function(currentHeight) {
- var updatedRanges = helpers.calculateScaleRange(
- dataTotal(),
- currentHeight,
- this.fontSize,
- this.beginAtZero,
- this.integersOnly
- );
- helpers.extend(this, updatedRanges);
- },
- xLabels: labels,
- font: helpers.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily),
- lineWidth: this.options.scaleLineWidth,
- lineColor: this.options.scaleLineColor,
- showHorizontalLines: this.options.scaleShowHorizontalLines,
- showVerticalLines: this.options.scaleShowVerticalLines,
- /// ZUI change begin
- showBeyondLine: this.options.scaleShowBeyondLine,
- /// ZUI change end
- gridLineWidth: (this.options.scaleShowGridLines) ? this.options.scaleGridLineWidth : 0,
- gridLineColor: (this.options.scaleShowGridLines) ? this.options.scaleGridLineColor : "rgba(0,0,0,0)",
- padding: (this.options.showScale) ? 0 : (this.options.barShowStroke) ? this.options.barStrokeWidth : 0,
- showLabels: this.options.scaleShowLabels,
- display: this.options.showScale
- };
-
- if(this.options.scaleOverride) {
- helpers.extend(scaleOptions, {
- calculateYRange: helpers.noop,
- steps: this.options.scaleSteps,
- stepValue: this.options.scaleStepWidth,
- min: this.options.scaleStartValue,
- max: this.options.scaleStartValue + (this.options.scaleSteps * this.options.scaleStepWidth)
- });
- }
-
- this.scale = new this.ScaleClass(scaleOptions);
- },
- addData: function(valuesArray, label) {
- //Map the values array for each of the datasets
- helpers.each(valuesArray, function(value, datasetIndex) {
- //Add a new point for each piece of data, passing any required data to draw.
- this.datasets[datasetIndex].bars.push(new this.BarClass({
- value: value,
- label: label,
- x: this.scale.calculateBarX(this.datasets.length, datasetIndex, this.scale.valuesCount + 1),
- y: this.scale.endPoint,
- width: this.scale.calculateBarWidth(this.datasets.length),
- base: this.scale.endPoint,
- strokeColor: this.datasets[datasetIndex].strokeColor,
- fillColor: this.datasets[datasetIndex].fillColor
- }));
- }, this);
-
- this.scale.addXLabel(label);
- //Then re-render the chart.
- this.update();
- },
- removeData: function() {
- this.scale.removeXLabel();
- //Then re-render the chart.
- helpers.each(this.datasets, function(dataset) {
- dataset.bars.shift();
- }, this);
- this.update();
- },
- reflow: function() {
- helpers.extend(this.BarClass.prototype, {
- y: this.scale.endPoint,
- base: this.scale.endPoint
- });
- var newScaleProps = helpers.extend({
- height: this.chart.height,
- width: this.chart.width
- });
- this.scale.update(newScaleProps);
- },
- /// ZUI change begin
- drawLabel: function(bar, placement) {
- var options = this.options;
- placement = placement || options.scaleValuePlacement;
- placement = placement ? placement.toLowerCase() : 'auto';
- if(placement === 'auto') {
- placement = bar.y < 15 ? 'insdie' : 'outside';
- }
-
- var y = placement === 'insdie' ? (bar.y + 10) : (bar.y - 10);
- var ctx = this.chart.ctx;
- ctx.font = helpers.fontString(options.scaleFontSize, options.scaleFontStyle, options.scaleFontFamily);
- ctx.textBaseline = "middle";
- ctx.textAlign = "center";
- ctx.fillStyle = options.scaleFontColor;
- ctx.fillText(bar.value, bar.x, y);
- },
- /// ZUI change end
- draw: function(ease) {
- var easingDecimal = ease || 1;
- this.clear();
-
- var ctx = this.chart.ctx;
-
- this.scale.draw(easingDecimal);
-
- /// ZUI change begin
- var showScaleValue = this.options.scaleShowLabels && this.options.scaleValuePlacement;
- /// ZUI change end
- //Draw all the bars for each dataset
- helpers.each(this.datasets, function(dataset, datasetIndex) {
- helpers.each(dataset.bars, function(bar, index) {
- if(bar.hasValue()) {
- bar.base = this.scale.endPoint;
- //Transition then draw
- bar.transition({
- x: this.scale.calculateBarX(this.datasets.length, datasetIndex, index),
- y: this.scale.calculateY(bar.value),
- width: this.scale.calculateBarWidth(this.datasets.length)
- }, easingDecimal).draw();
- }
- /// ZUI change begin
- if(showScaleValue) {
- this.drawLabel(bar);
- }
- /// ZUI change end
- }, this);
-
- }, this);
- }
- });
-
- /// ----- ZUI change begin -----
- /// Use jquery object to create Chart object
- $.fn.barChart = function(data, options) {
- var barCharts = [];
- this.each(function() {
- var $this = $(this);
- barCharts.push(new Chart(this.getContext("2d")).Bar(data, $.extend($this.data(), options)));
- });
- return barCharts.length === 1 ? barCharts[0] : barCharts;
- }
-
- /// ----- ZUI change end -----
-
- /// ----- ZUI change begin -----
- /// Add jquery object to namespace
-
- /// }).call(this); // Old code
-}).call(this, jQuery);
-
-/// ----- ZUI change end -----
-
-
-/* ========================================================================
- * Datetimepicker: bootstrap-datetimepicker.js
- * http://www.malot.fr/bootstrap-datetimepicker
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright 2012 Stefan Petre
- * Improvements by Andrew Rowls
- * Improvements by Sébastien Malot
- * Improvements by Yun Lai
- * Improvement by CuGBabyBeaR @ 2013-09-12
- * Project URL : http://www.malot.fr/bootstrap-datetimepicker
- *
- * 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.
- * ========================================================================
- * Improvement in ZUI:
- * 1. Determine client language and apply setting automatically.
- * 2. New option for 'pickerPosition':
- * - 'auto-left';
- * - 'auto-right'.
- * ======================================================================== */
-
-
-/*!
+function(t){"use strict";var e=t&&t.zui?t.zui:this,i=(e.Chart,function(t){this.canvas=t.canvas,this.ctx=t;var e=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},i=this.width=e(t.canvas,"Width"),n=this.height=e(t.canvas,"Height");t.canvas.width=i,t.canvas.height=n;var i=this.width=t.canvas.width,n=this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this});i.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},i.types={};var s=i.helpers={},n=s.each=function(t,e,i){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(e(n))return n}},s.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},s=function(){this.constructor=i};return s.prototype=e.prototype,i.prototype=new s,i.extend=h,t&&o(i.prototype,t),i.__super__=e.prototype,i}),c=s.noop=function(){},d=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),u=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof define&&define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,e,i){if(f(e)){if(t>e)return e}else if(f(i)&&t=o,l=g(t),h=m(t);l===h&&(l+=.5,h>=.5&&!s?h-=.5:l+=.5);for(var c=Math.abs(l-h),d=w(c),u=Math.ceil(l/(1*Math.pow(10,d)))*Math.pow(10,d),p=s?0:Math.floor(h/(1*Math.pow(10,d)))*Math.pow(10,d),f=u-p,v=Math.pow(10,d),y=Math.round(f/v);(y>o||2*yo)v*=2,y=Math.round(f/v),y%1!==0&&(r=!0);else if(n&&d>=0){if(v/2%1!==0)break;v/=2,y=Math.round(f/v)}else v/=2,y=Math.round(f/v);return r&&(y=a,v=f/y),{steps:y,stepValue:v,min:p,max:p+y*v}},s.template=function(t,e){function i(t,e){var i=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return e?i(e):i}if(t instanceof Function)return t(e);var s={};return i(t,e)}),_=(s.generateLabels=function(t,e,i,s){var a=new Array(e);return labelTemplateString&&n(a,function(e,n){a[n]=x(t,{value:i+s*(n+1)})}),a},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),ss?i:s}),s},E=s.drawRoundedRectangle=function(t,e,i,s,n,a){t.beginPath(),t.moveTo(e+a,i),t.lineTo(e+s-a,i),t.quadraticCurveTo(e+s,i,e+s,i+a),t.lineTo(e+s,i+n-a),t.quadraticCurveTo(e+s,i+n,e+s-a,i+n),t.lineTo(e+a,i+n),t.quadraticCurveTo(e,i+n,e,i+n-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+a,i),t.closePath()};i.instances={},i.Type=function(t,e,s){this.options=e,this.chart=s,this.id=d(),i.instances[this.id]=this,e.responsive&&this.resize(),this.initialize.call(this,t)},o(i.Type.prototype,{initialize:function(){return this},clear:function(){return L(this.chart),this},stop:function(){return k(this.animationFrame),this},resize:function(t){this.stop();var e=this.chart.canvas,i=M(this.chart.canvas),s=this.options.maintainAspectRatio?i/this.chart.aspectRatio:P(this.chart.canvas);return e.width=this.chart.width=i,e.height=this.chart.height=s,F(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return x(this.options.legendTemplate,this)},destroy:function(){this.clear(),D(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete i.instances[this.id]},showTooltip:function(t,e){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var a=function(t){var e=!1;return t.length!==this.activeElements.length?e=!0:(n(t,function(t,i){t!==this.activeElements[i]&&(e=!0)},this),e)}.call(this,t);if(a||e){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.datasets&&this.datasets.length>1){for(var o,r,h=this.datasets.length-1;h>=0&&(o=this.datasets[h].points||this.datasets[h].bars||this.datasets[h].segments,r=l(o,t[0]),r===-1);h--);var c=[],d=[],u=function(t){var e,i,n,a,o,l=[],h=[],u=[];return s.each(this.datasets,function(t){t.showTooltips!==!1&&(e=t.points||t.bars||t.segments,e[r]&&e[r].hasValue()&&l.push(e[r]))}),s.each(l,function(t){h.push(t.x),u.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),d.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(u),n=g(u),a=m(h),i=g(h),{x:a>this.chart.width/2?a:i,y:(o+n)/2}}.call(this,r);new i.MultiTooltip({x:u.x,y:u.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:d,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx,custom:this.options.customTooltips}).draw()}else n(t,function(t){var e=t.tooltipPosition();new i.Tooltip({x:Math.round(e.x),y:Math.round(e.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:x(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),i.Type.extend=function(t){var e=this,s=function(){return e.apply(this,arguments)};if(s.prototype=a(e.prototype),o(s.prototype,t),s.extend=i.Type.extend,t.name||e.prototype.name){var n=t.name||e.prototype.name,l=i.defaults[e.prototype.name]?a(i.defaults[e.prototype.name]):{};i.defaults[n]=o(l,t.defaults),i.types[n]=s,i.prototype[n]=function(t,e){var a=r(i.defaults.global,i.defaults[n],e||{});return new s(t,a,this)}}else u("Name not provided for this chart, so it hasn't been registered");return e},i.Element=function(t){o(this,t),this.initialize.apply(this,arguments),this.save()},o(i.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):o(this,this._saved),this},save:function(){return this._saved=a(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,e){this._saved[e]=this[e],this[e]=t},this),this},transition:function(t,e){return n(t,function(t,i){this[i]=(t-this._saved[i])*e+this._saved[i]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return f(this.value)}}),i.Element.extend=h,i.Point=i.Element.extend({display:!0,inRange:function(t,e){var i=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(e-this.y,2)=this.startAngle&&i.angle<=this.endAngle,a=i.distance>=this.innerRadius&&i.distance<=this.outerRadius;return n&&a},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,e=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*e,y:this.y+Math.sin(t)*e}},draw:function(t){var e=this.ctx;if(e.beginPath(),e.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),e.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),e.closePath(),e.strokeStyle=this.strokeColor,e.lineWidth=this.strokeWidth,e.fillStyle=this.fillColor,e.fill(),e.lineJoin="bevel",this.showStroke&&e.stroke(),this.circleBeginEnd){var i=(this.outerRadius+this.innerRadius)/2,s=(this.outerRadius-this.innerRadius)/2;e.beginPath(),e.arc(this.x+Math.cos(this.startAngle)*i,this.y+Math.sin(this.startAngle)*i,s,0,2*Math.PI),e.closePath(),e.fill(),e.beginPath(),e.arc(this.x+Math.cos(this.endAngle)*i,this.y+Math.sin(this.endAngle)*i,s,0,2*Math.PI),e.closePath(),e.fill()}}}),i.Rectangle=i.Element.extend({draw:function(){var t=this.ctx,e=this.width/2,i=this.x-e,s=this.x+e,n=this.base-(this.base-this.y),a=this.strokeWidth/2;this.showStroke&&(i+=a,s-=a,n+=a),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(i,this.base),t.lineTo(i,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,e){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&e>=this.y&&e<=this.base}}),i.Tooltip=i.Element.extend({draw:function(){var t=this.chart.ctx;t.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var e=this.caretPadding=2,i=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+e;this.x+i/2>this.chart.width?this.xAlign="left":this.x-i/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var a=this.x-i/2,o=this.y-n;if(t.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-e),t.lineTo(this.x+this.caretHeight,this.y-(e+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(e+this.caretHeight)),t.closePath(),t.fill();break;case"below":o=this.y+e+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+e),t.lineTo(this.x+this.caretHeight,this.y+e+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+e+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":a=this.x-i+(this.cornerRadius+this.caretHeight);break;case"right":a=this.x-(this.cornerRadius+this.caretHeight)}E(t,a,o,i,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,a+i/2,o+s/2)}}}),i.MultiTooltip=i.Element.extend({initialize:function(){this.font=z(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=z(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,e=$(this.ctx,this.font,this.labels)+this.fontSize+3,i=g([e,t]);this.width=i+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var e=this.y-this.height/2+this.yPadding,i=t-1;return 0===t?e+this.titleFontSize/2:e+(1.5*this.fontSize*i+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{E(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(e,i){t.fillStyle=this.textColor,t.fillText(e,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(i+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[i].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(i+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),i.Scale=i.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?$(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,e=this.endPoint-this.startPoint;for(this.calculateYRange(e),this.buildYLabels(),this.calculateXLabelRotation();e>this.endPoint-this.startPoint;)e=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(e),this.buildYLabels(),tthis.yLabelWidth+10?i/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,a=$(this.ctx,this.font,this.xLabels);this.xLabelWidth=a;for(var o=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>o&&0===this.xLabelRotation||this.xLabelWidth>o&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(y(this.xLabelRotation)),t=n*i,e=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*a;this.xLabelRotation>0&&(this.endPoint-=Math.sin(y(this.xLabelRotation))*a+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var e=this.drawingArea()/(this.min-this.max);return this.endPoint-e*(t-this.min)},calculateX:function(t){var e=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),i=e/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=i*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=i/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,e=(this.endPoint-this.startPoint)/this.steps,i=Math.round(this.xScalePaddingLeft);if(this.display){t.fillStyle=this.textColor,t.font=this.font;var a=this.showBeyondLine?5:0;n(this.yLabels,function(n,o){var r=this.endPoint-e*o,l=Math.round(r),h=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,i-10,r),0!==o||h||(h=!0),h&&t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),l+=s.aliasPixel(t.lineWidth),h&&(t.moveTo(i,l),t.lineTo(this.width,l),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(i-a,l),t.lineTo(i,l),t.stroke(),t.closePath()},this),n(this.xLabels,function(e,i){var s=this.calculateX(i)+b(this.lineWidth),n=this.calculateX(i-(this.offsetGridLines?.5:0))+b(this.lineWidth),o=this.xLabelRotation>0,r=this.showVerticalLines;0!==i||r||(r=!0),r&&t.beginPath(),i>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),r&&(t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+a),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(y(this.xLabelRotation)*-1),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(e,0,0),t.restore()},this)}}}),i.RadialScale=i.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var e=this.drawingArea/(this.max-this.min);return(t-this.min)*e},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),e=0;e<=this.steps;e++)this.yLabels.push(x(this.templateString,{value:(this.min+e*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,e,i,s,n,a,o,r,l,h,c,d,u=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),e=0;ep&&(p=t.x+s,n=e),t.x-sp&&(p=t.x+i,n=e):e>this.valuesCount/2&&t.x-i0){var s,n=i*(this.drawingArea/this.steps),a=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var o=0;o=0;e--){if(this.angleLineWidth>0){var i=this.getPointPosition(e,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(i.x,i.y),t.stroke(),t.closePath()}var s=this.getPointPosition(e,this.calculateCenterOffset(this.max)+5);t.font=z(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var a=this.labels.length,o=this.labels.length/2,r=o/2,l=ea-r,h=e===r||e===a-r;0===e?t.textAlign="center":e===o?t.textAlign="center":e<% for (var i=0; i<%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>'};i.Type.extend({name:"Line",defaults:n,initialize:function(e){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)0&ðis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(i.lineTo(r[r.length-1].x,this.scale.endPoint),i.lineTo(r[0].x,this.scale.endPoint),i.fillStyle=t.fillColor,i.closePath(),i.fill()),s.each(r,function(t){t.draw()})},this)}}),t.fn.lineChart=function(e,s){var n=[];return this.each(function(){var a=t(this);n.push(new i(this.getContext("2d")).Line(e,t.extend(a.data(),s)))}),1===n.length?n[0]:n}}.call(this,jQuery),function(t){"use strict";var e=t&&t.zui?t.zui:this,i=e.Chart,s=i.helpers,n={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:1,percentageInnerCutout:50,scaleShowLabels:!1,scaleLabel:"<%=value%>",scaleLabelPlacement:"auto",animationSteps:60,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<% for (var i=0; i- <%if(segments[i].label){%><%=segments[i].label%><%}%>
<%}%> '};i.Type.extend({name:"Doughnut",defaults:n,initialize:function(t){this.segments=[],this.outerRadius=(s.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&s.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];s.each(this.segments,function(t){t.restore(["fillColor"])}),s.each(e,function(t){t.fillColor=t.highlightColor}),this.showTooltip(e)}),this.calculateTotal(t),s.each(t,function(t,e){this.addData(t,e,!0)},this),this.render()},getSegmentsAtEvent:function(t){var e=[],i=s.getRelativePosition(t);return s.each(this.segments,function(t){t.inRange(i.x,i.y)&&e.push(t)},this),e},addData:function(e,i,s){if(t.zui&&t.zui.Color&&t.zui.Color.get){var n=new t.zui.Color.get(e.color);e.color=n.toCssStr(),e.highlight||(e.highlight=n.lighten(5).toCssStr())}var a=i||this.segments.length;this.segments.splice(a,0,new this.SegmentArc({id:"undefined"==typeof e.id?a:e.id,value:e.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:e.color,highlightColor:e.highlight||e.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(e.value),showLabel:e.showLabel!==!1,circleBeginEnd:e.circleBeginEnd,label:e.label})),s||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(Math.abs(t)/this.total)},calculateTotal:function(t){this.total=0,s.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.calculateTotal(this.segments),s.each(this.activeElements,function(t){t.restore(["fillColor"])}),s.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var e=s.isNumber(t)?t:this.segments.length-1;this.segments.splice(e,1),this.reflow(),this.update()},reflow:function(){s.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(s.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,s.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},drawLabel:function(e,i,n){var a=this.options,o=(e.endAngle+e.startAngle)/2,r=a.scaleLabelPlacement;"inside"!==r&&"outside"!==r&&this.chart.width-this.chart.height>50&&e.circumference=0,g=l+u,m=h+p;d.textAlign=f?"left":"right",d.measureText(c).width,l=f?Math.max(u+e.outerRadius+10,l+30+u):Math.min(u-e.outerRadius-10,l-30+u);var v=a.scaleFontSize*(a.scaleLineHeight||1),y=Math.round((.8*h+p)/v)+1,b=(Math.floor(this.chart.width/v)+1,f?1:-1);if(n[y*b]&&(y>1?y--:y++),n[y*b])return;h=(y-1)*v+a.scaleFontSize/2,n[y*b]=!0,d.beginPath(),d.moveTo(g,m),d.lineTo(l,h),l=f?l+5:l-5,d.lineTo(l,h),d.strokeStyle=t.zui&&t.zui.Color?new t.zui.Color(e.fillColor).fade(40).toCssStr():e.fillColor,d.strokeWidth=a.scaleLineWidth,d.stroke(),d.fillStyle=e.fillColor}else l=.7*l+u,h=.7*h+p,d.fillStyle=t.zui&&t.zui.Color?new t.zui.Color(e.fillColor).contrast().toCssStr():"#fff";d.fillText(c,l,h)},draw:function(t){var e=t?t:1;this.clear();var i;if(s.each(this.segments,function(t,i){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},e),t.endAngle=t.startAngle+t.circumference,this.options.reverseDrawOrder||t.draw(),0===i&&(t.startAngle=1.5*Math.PI),i<% for (var i=0; i<%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>'};i.Type.extend({name:"Bar",defaults:n,initialize:function(e){var n=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,e,i){var s=this.calculateBaseWidth(),a=this.calculateX(i)-s/2,o=this.calculateBarWidth(t);return a+o*e+e*n.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*n.barValueSpacing},calculateBarWidth:function(t){var e=this.calculateBaseWidth()-(t-1)*n.barDatasetSpacing;return e/t}}),this.datasets=[],this.options.showTooltips&&s.bindEvents(this,this.options.tooltipEvents,function(t){var e="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),s.each(e,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(e)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),s.each(e.datasets,function(i,n){if(t.zui&&t.zui.Color&&t.zui.Color.get){var a=t.zui.Color.get(i.color),o=a.toCssStr();i.fillColor||(i.fillColor=a.clone().fade(50).toCssStr()),i.strokeColor||(i.strokeColor=o)}var r={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(r),s.each(i.data,function(t,s){r.bars.push(new this.BarClass({value:t,label:e.labels[s],datasetLabel:i.label,strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(e.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,e,i){s.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,i,e),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),s.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){s.each(this.datasets,function(e,i){s.each(e.bars,t,this,i)},this)},getBarsAtEvent:function(t){for(var e,i=[],n=s.getRelativePosition(t),a=function(t){i.push(t.bars[e])},o=0;o= this.startDate && d <= this.endDate) {
- this.date = d;
- this.setValue();
- this.viewDate = this.date;
- this.fill();
- } else {
- this.element.trigger({
- type: 'outOfRange',
- date: d,
- startDate: this.startDate,
- endDate: this.endDate
- });
- }
- },
-
- setFormat: function(format) {
- this.format = DPGlobal.parseFormat(format, this.formatType);
- var element;
- if(this.isInput) {
- element = this.element;
- } else if(this.component) {
- element = this.element.find('input');
- }
- if(element && element.val()) {
- this.setValue();
- }
- },
-
- setValue: function() {
- var formatted = this.getFormattedDate();
- if(!this.isInput) {
- if(this.component) {
- this.element.find('input').val(formatted);
- }
- this.element.data('date', formatted);
- } else {
- this.element.val(formatted);
- }
- if(this.linkField) {
- $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
- }
- },
-
- getFormattedDate: function(format) {
- if(format == undefined) format = this.format;
- return DPGlobal.formatDate(this.date, format, this.language, this.formatType);
- },
-
- setStartDate: function(startDate) {
- this.startDate = startDate || -Infinity;
- if(this.startDate !== -Infinity) {
- this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType);
- }
- this.update();
- this.updateNavArrows();
- },
-
- setEndDate: function(endDate) {
- this.endDate = endDate || Infinity;
- if(this.endDate !== Infinity) {
- this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType);
- }
- this.update();
- this.updateNavArrows();
- },
-
- setDaysOfWeekDisabled: function(daysOfWeekDisabled) {
- this.daysOfWeekDisabled = daysOfWeekDisabled || [];
- if(!$.isArray(this.daysOfWeekDisabled)) {
- this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
- }
- this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function(d) {
- return parseInt(d, 10);
- });
- this.update();
- this.updateNavArrows();
- },
-
- place: function() {
- if(this.isInline) return;
-
- var index_highest = 0;
- $('div').each(function() {
- var index_current = parseInt($(this).css("zIndex"), 10);
- if(index_current > index_highest) {
- index_highest = index_current;
- }
- });
- var zIndex = index_highest + 10;
-
- var offset, top, left;
- if(this.component) {
- offset = this.component.offset();
- left = offset.left;
- if(this.pickerPosition === 'bottom-left' || this.pickerPosition === 'top-left' || this.pickerPosition === 'auto-left') {
- left += this.component.outerWidth() - this.picker.outerWidth();
- }
- } else {
- offset = this.element.offset();
- left = offset.left;
- }
-
- var isAutoPosition = this.pickerPosition.indexOf('auto-') === 0;
- var realPickerPosition = isAutoPosition ? (((offset.top + this.picker.outerHeight() > $(window).height() + $(window).scrollTop()) ? 'top' : 'bottom') + (this.pickerPosition.lastIndexOf('-left') === 0 ? '-left' : '-right')) : this.pickerPosition;
-
- if(realPickerPosition === 'top-left' || realPickerPosition === 'top-right') {
- top = offset.top - this.picker.outerHeight();
- } else {
- top = offset.top + this.height;
- }
- this.picker.css({
- top: top,
- left: left,
- zIndex: zIndex
- }).attr('class', 'datetimepicker dropdown-menu datetimepicker-dropdown-' + realPickerPosition);
- if(this.pickerClass) this.picker.addClass(this.pickerClass);
- if(this.pickerId) this.picker.attr('id', this.pickerId);
- },
-
- update: function() {
- var date, fromArgs = false;
- if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
- date = arguments[0];
- fromArgs = true;
- } else {
- date = this.element.data('date') || (this.isInput ? this.element.val() : this.element.find('input').val()) || this.initialDate;
- if(typeof date == 'string' || date instanceof String) {
- date = date.replace(/^\s+|\s+$/g, '');
- }
- }
-
- if(!date) {
- date = new Date();
- fromArgs = false;
- }
-
- this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType);
-
- if(fromArgs) this.setValue();
-
- if(this.date < this.startDate) {
- this.viewDate = new Date(this.startDate);
- } else if(this.date > this.endDate) {
- this.viewDate = new Date(this.endDate);
- } else {
- this.viewDate = new Date(this.date);
- }
- this.fill();
- },
-
- fillDow: function() {
- var dowCnt = this.weekStart,
- html = '';
- while(dowCnt < this.weekStart + 7) {
- html += '| ' + dates[this.language].daysMin[(dowCnt++) % 7] + ' | ';
- }
- html += ' ';
- this.picker.find('.datetimepicker-days thead').append(html);
- },
-
- fillMonths: function() {
- var html = '',
- i = 0;
- while(i < 12) {
- html += '' + dates[this.language].monthsShort[i++] + '';
- }
- this.picker.find('.datetimepicker-months td').html(html);
- },
-
- fill: function() {
- if(this.date == null || this.viewDate == null) {
- return;
- }
- var d = new Date(this.viewDate),
- year = d.getUTCFullYear(),
- month = d.getUTCMonth(),
- dayMonth = d.getUTCDate(),
- hours = d.getUTCHours(),
- minutes = d.getUTCMinutes(),
- startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
- startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
- endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
- endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
- currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
- today = new Date();
- this.picker.find('.datetimepicker-days thead th:eq(1)')
- .text(dates[this.language].months[month] + ' ' + year);
- if(this.formatViewType == "time") {
- var hourConverted = hours % 12 ? hours % 12 : 12;
- var hoursDisplay = (hourConverted < 10 ? '0' : '') + hourConverted;
- var minutesDisplay = (minutes < 10 ? '0' : '') + minutes;
- var meridianDisplay = dates[this.language].meridiem[hours < 12 ? 0 : 1];
- this.picker.find('.datetimepicker-hours thead th:eq(1)')
- .text(hoursDisplay + ':' + minutesDisplay + ' ' + meridianDisplay.toUpperCase());
- this.picker.find('.datetimepicker-minutes thead th:eq(1)')
- .text(hoursDisplay + ':' + minutesDisplay + ' ' + meridianDisplay.toUpperCase());
- } else {
- this.picker.find('.datetimepicker-hours thead th:eq(1)')
- .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
- this.picker.find('.datetimepicker-minutes thead th:eq(1)')
- .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
- }
- this.picker.find('tfoot th.today')
- .text(dates[this.language].today)
- .toggle(this.todayBtn !== false);
- this.updateNavArrows();
- this.fillMonths();
- /*var prevMonth = UTCDate(year, month, 0,0,0,0,0);
- prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);*/
- var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
- day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
- prevMonth.setUTCDate(day);
- prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
- var nextMonth = new Date(prevMonth);
- nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
- nextMonth = nextMonth.valueOf();
- var html = [];
- var clsName;
- while(prevMonth.valueOf() < nextMonth) {
- if(prevMonth.getUTCDay() == this.weekStart) {
- html.push('');
- }
- clsName = '';
- if(prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
- clsName += ' old';
- } else if(prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
- clsName += ' new';
- }
- // Compare internal UTC date with local today, not UTC today
- if(this.todayHighlight &&
- prevMonth.getUTCFullYear() == today.getFullYear() &&
- prevMonth.getUTCMonth() == today.getMonth() &&
- prevMonth.getUTCDate() == today.getDate()) {
- clsName += ' today';
- }
- if(prevMonth.valueOf() == currentDate) {
- clsName += ' active';
- }
- if((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate ||
- $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
- clsName += ' disabled';
- }
- html.push('| ' + prevMonth.getUTCDate() + ' | ');
- if(prevMonth.getUTCDay() == this.weekEnd) {
- html.push(' ');
- }
- prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
- }
- this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
-
- html = [];
- var txt = '',
- meridian = '',
- meridianOld = '';
- for(var i = 0; i < 24; i++) {
- var actual = UTCDate(year, month, dayMonth, i);
- clsName = '';
- // We want the previous hour for the startDate
- if((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
- clsName += ' disabled';
- } else if(hours == i) {
- clsName += ' active';
- }
- if(this.showMeridian && dates[this.language].meridiem.length == 2) {
- meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
- if(meridian != meridianOld) {
- if(meridianOld != '') {
- html.push('');
- }
- html.push('');
- }
- } else {
- txt = i + ':00';
- html.push('' + txt + '');
- }
- }
- this.picker.find('.datetimepicker-hours td').html(html.join(''));
-
- html = [];
- txt = '', meridian = '', meridianOld = '';
- for(var i = 0; i < 60; i += this.minuteStep) {
- var actual = UTCDate(year, month, dayMonth, hours, i, 0);
- clsName = '';
- if(actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
- clsName += ' disabled';
- } else if(Math.floor(minutes / this.minuteStep) == Math.floor(i / this.minuteStep)) {
- clsName += ' active';
- }
- if(this.showMeridian && dates[this.language].meridiem.length == 2) {
- meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
- if(meridian != meridianOld) {
- if(meridianOld != '') {
- html.push('');
- }
- html.push('');
- }
- } else {
- txt = i + ':00';
- //html.push(''+txt+'');
- html.push('' + hours + ':' + (i < 10 ? '0' + i : i) + '');
- }
- }
- this.picker.find('.datetimepicker-minutes td').html(html.join(''));
-
- var currentYear = this.date.getUTCFullYear();
- var months = this.picker.find('.datetimepicker-months')
- .find('th:eq(1)')
- .text(year)
- .end()
- .find('span').removeClass('active');
- if(currentYear == year) {
- months.eq(this.date.getUTCMonth()).addClass('active');
- }
- if(year < startYear || year > endYear) {
- months.addClass('disabled');
- }
- if(year == startYear) {
- months.slice(0, startMonth).addClass('disabled');
- }
- if(year == endYear) {
- months.slice(endMonth + 1).addClass('disabled');
- }
-
- html = '';
- year = parseInt(year / 10, 10) * 10;
- var yearCont = this.picker.find('.datetimepicker-years')
- .find('th:eq(1)')
- .text(year + '-' + (year + 9))
- .end()
- .find('td');
- year -= 1;
- for(var i = -1; i < 11; i++) {
- html += '' + year + '';
- year += 1;
- }
- yearCont.html(html);
- this.place();
- },
-
- updateNavArrows: function() {
- var d = new Date(this.viewDate),
- year = d.getUTCFullYear(),
- month = d.getUTCMonth(),
- day = d.getUTCDate(),
- hour = d.getUTCHours();
- switch(this.viewMode) {
- case 0:
- if(this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate() && hour <= this.startDate.getUTCHours()) {
- this.picker.find('.prev').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.prev').css({
- visibility: 'visible'
- });
- }
- if(this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate() && hour >= this.endDate.getUTCHours()) {
- this.picker.find('.next').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.next').css({
- visibility: 'visible'
- });
- }
- break;
- case 1:
- if(this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth() && day <= this.startDate.getUTCDate()) {
- this.picker.find('.prev').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.prev').css({
- visibility: 'visible'
- });
- }
- if(this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth() && day >= this.endDate.getUTCDate()) {
- this.picker.find('.next').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.next').css({
- visibility: 'visible'
- });
- }
- break;
- case 2:
- if(this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
- this.picker.find('.prev').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.prev').css({
- visibility: 'visible'
- });
- }
- if(this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
- this.picker.find('.next').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.next').css({
- visibility: 'visible'
- });
- }
- break;
- case 3:
- case 4:
- if(this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
- this.picker.find('.prev').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.prev').css({
- visibility: 'visible'
- });
- }
- if(this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
- this.picker.find('.next').css({
- visibility: 'hidden'
- });
- } else {
- this.picker.find('.next').css({
- visibility: 'visible'
- });
- }
- break;
- }
- },
-
- mousewheel: function(e) {
-
- e.preventDefault();
- e.stopPropagation();
-
- if(this.wheelPause) {
- return;
- }
-
- this.wheelPause = true;
-
- var originalEvent = e.originalEvent;
-
- var delta = originalEvent.wheelDelta;
-
- var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
-
- if(this.wheelViewModeNavigationInverseDirection) {
- mode = -mode;
- }
-
- this.showMode(mode);
-
- setTimeout($.proxy(function() {
-
- this.wheelPause = false
-
- }, this), this.wheelViewModeNavigationDelay);
-
- },
-
- click: function(e) {
- e.stopPropagation();
- e.preventDefault();
- var target = $(e.target).closest('span, td, th, legend');
- if(target.length == 1) {
- if(target.is('.disabled')) {
- this.element.trigger({
- type: 'outOfRange',
- date: this.viewDate,
- startDate: this.startDate,
- endDate: this.endDate
- });
- return;
- }
- switch(target[0].nodeName.toLowerCase()) {
- case 'th':
- switch(target[0].className) {
- case 'switch':
- this.showMode(1);
- break;
- case 'prev':
- case 'next':
- var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
- switch(this.viewMode) {
- case 0:
- this.viewDate = this.moveHour(this.viewDate, dir);
- break;
- case 1:
- this.viewDate = this.moveDate(this.viewDate, dir);
- break;
- case 2:
- this.viewDate = this.moveMonth(this.viewDate, dir);
- break;
- case 3:
- case 4:
- this.viewDate = this.moveYear(this.viewDate, dir);
- break;
- }
- this.fill();
- break;
- case 'today':
- var date = new Date();
- date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
-
- // Respect startDate and endDate.
- if(date < this.startDate) date = this.startDate;
- else if(date > this.endDate) date = this.endDate;
-
- this.viewMode = this.startViewMode;
- this.showMode(0);
- this._setDate(date);
- this.fill();
- if(this.autoclose) {
- this.hide();
- }
- break;
- }
- break;
- case 'span':
- if(!target.is('.disabled')) {
- var year = this.viewDate.getUTCFullYear(),
- month = this.viewDate.getUTCMonth(),
- day = this.viewDate.getUTCDate(),
- hours = this.viewDate.getUTCHours(),
- minutes = this.viewDate.getUTCMinutes(),
- seconds = this.viewDate.getUTCSeconds();
-
- if(target.is('.month')) {
- this.viewDate.setUTCDate(1);
- month = target.parent().find('span').index(target);
- day = this.viewDate.getUTCDate();
- this.viewDate.setUTCMonth(month);
- this.element.trigger({
- type: 'changeMonth',
- date: this.viewDate
- });
- if(this.viewSelect >= 3) {
- this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
- }
- } else if(target.is('.year')) {
- this.viewDate.setUTCDate(1);
- year = parseInt(target.text(), 10) || 0;
- this.viewDate.setUTCFullYear(year);
- this.element.trigger({
- type: 'changeYear',
- date: this.viewDate
- });
- if(this.viewSelect >= 4) {
- this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
- }
- } else if(target.is('.hour')) {
- hours = parseInt(target.text(), 10) || 0;
- if(target.hasClass('hour_am') || target.hasClass('hour_pm')) {
- if(hours == 12 && target.hasClass('hour_am')) {
- hours = 0;
- } else if(hours != 12 && target.hasClass('hour_pm')) {
- hours += 12;
- }
- }
- this.viewDate.setUTCHours(hours);
- this.element.trigger({
- type: 'changeHour',
- date: this.viewDate
- });
- if(this.viewSelect >= 1) {
- this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
- }
- } else if(target.is('.minute')) {
- minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
- this.viewDate.setUTCMinutes(minutes);
- this.element.trigger({
- type: 'changeMinute',
- date: this.viewDate
- });
- if(this.viewSelect >= 0) {
- this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
- }
- }
- if(this.viewMode != 0) {
- var oldViewMode = this.viewMode;
- this.showMode(-1);
- this.fill();
- if(oldViewMode == this.viewMode && this.autoclose) {
- this.hide();
- }
- } else {
- this.fill();
- if(this.autoclose) {
- this.hide();
- }
- }
- }
- break;
- case 'td':
- if(target.is('.day') && !target.is('.disabled')) {
- var day = parseInt(target.text(), 10) || 1;
- var year = this.viewDate.getUTCFullYear(),
- month = this.viewDate.getUTCMonth(),
- hours = this.viewDate.getUTCHours(),
- minutes = this.viewDate.getUTCMinutes(),
- seconds = this.viewDate.getUTCSeconds();
- if(target.is('.old')) {
- if(month === 0) {
- month = 11;
- year -= 1;
- } else {
- month -= 1;
- }
- } else if(target.is('.new')) {
- if(month == 11) {
- month = 0;
- year += 1;
- } else {
- month += 1;
- }
- }
- this.viewDate.setUTCFullYear(year);
- this.viewDate.setUTCMonth(month, day);
- this.element.trigger({
- type: 'changeDay',
- date: this.viewDate
- });
- if(this.viewSelect >= 2) {
- this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
- }
- }
- var oldViewMode = this.viewMode;
- this.showMode(-1);
- this.fill();
- if(oldViewMode == this.viewMode && this.autoclose) {
- this.hide();
- }
- break;
- }
- }
- },
-
- _setDate: function(date, which) {
- if(!which || which == 'date')
- this.date = date;
- if(!which || which == 'view')
- this.viewDate = date;
- this.fill();
- this.setValue();
- var element;
- if(this.isInput) {
- element = this.element;
- } else if(this.component) {
- element = this.element.find('input');
- }
- if(element) {
- element.change();
- if(this.autoclose && (!which || which == 'date')) {
- //this.hide();
- }
- }
- this.element.trigger({
- type: 'changeDate',
- date: this.date
- });
- if(date === null) {
- this.date = this.viewDate;
- }
- },
-
- moveMinute: function(date, dir) {
- if(!dir) return date;
- var new_date = new Date(date.valueOf());
- //dir = dir > 0 ? 1 : -1;
- new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
- return new_date;
- },
-
- moveHour: function(date, dir) {
- if(!dir) return date;
- var new_date = new Date(date.valueOf());
- //dir = dir > 0 ? 1 : -1;
- new_date.setUTCHours(new_date.getUTCHours() + dir);
- return new_date;
- },
-
- moveDate: function(date, dir) {
- if(!dir) return date;
- var new_date = new Date(date.valueOf());
- //dir = dir > 0 ? 1 : -1;
- new_date.setUTCDate(new_date.getUTCDate() + dir);
- return new_date;
- },
-
- moveMonth: function(date, dir) {
- if(!dir) return date;
- var new_date = new Date(date.valueOf()),
- day = new_date.getUTCDate(),
- month = new_date.getUTCMonth(),
- mag = Math.abs(dir),
- new_month, test;
- dir = dir > 0 ? 1 : -1;
- if(mag == 1) {
- test = dir == -1
- // If going back one month, make sure month is not current month
- // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
- ? function() {
- return new_date.getUTCMonth() == month;
- }
- // If going forward one month, make sure month is as expected
- // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
- : function() {
- return new_date.getUTCMonth() != new_month;
- };
- new_month = month + dir;
- new_date.setUTCMonth(new_month);
- // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
- if(new_month < 0 || new_month > 11)
- new_month = (new_month + 12) % 12;
- } else {
- // For magnitudes >1, move one month at a time...
- for(var i = 0; i < mag; i++)
- // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
- new_date = this.moveMonth(new_date, dir);
- // ...then reset the day, keeping it in the new month
- new_month = new_date.getUTCMonth();
- new_date.setUTCDate(day);
- test = function() {
- return new_month != new_date.getUTCMonth();
- };
- }
- // Common date-resetting loop -- if date is beyond end of month, make it
- // end of month
- while(test()) {
- new_date.setUTCDate(--day);
- new_date.setUTCMonth(new_month);
- }
- return new_date;
- },
-
- moveYear: function(date, dir) {
- return this.moveMonth(date, dir * 12);
- },
-
- dateWithinRange: function(date) {
- return date >= this.startDate && date <= this.endDate;
- },
-
- keydown: function(e) {
- if(this.picker.is(':not(:visible)')) {
- if(e.keyCode == 27) // allow escape to hide and re-show picker
- this.show();
- return;
- }
- var dateChanged = false,
- dir, day, month,
- newDate, newViewDate;
- switch(e.keyCode) {
- case 27: // escape
- this.hide();
- e.preventDefault();
- break;
- case 37: // left
- case 39: // right
- if(!this.keyboardNavigation) break;
- dir = e.keyCode == 37 ? -1 : 1;
- viewMode = this.viewMode;
- if(e.ctrlKey) {
- viewMode += 2;
- } else if(e.shiftKey) {
- viewMode += 1;
- }
- if(viewMode == 4) {
- newDate = this.moveYear(this.date, dir);
- newViewDate = this.moveYear(this.viewDate, dir);
- } else if(viewMode == 3) {
- newDate = this.moveMonth(this.date, dir);
- newViewDate = this.moveMonth(this.viewDate, dir);
- } else if(viewMode == 2) {
- newDate = this.moveDate(this.date, dir);
- newViewDate = this.moveDate(this.viewDate, dir);
- } else if(viewMode == 1) {
- newDate = this.moveHour(this.date, dir);
- newViewDate = this.moveHour(this.viewDate, dir);
- } else if(viewMode == 0) {
- newDate = this.moveMinute(this.date, dir);
- newViewDate = this.moveMinute(this.viewDate, dir);
- }
- if(this.dateWithinRange(newDate)) {
- this.date = newDate;
- this.viewDate = newViewDate;
- this.setValue();
- this.update();
- e.preventDefault();
- dateChanged = true;
- }
- break;
- case 38: // up
- case 40: // down
- if(!this.keyboardNavigation) break;
- dir = e.keyCode == 38 ? -1 : 1;
- viewMode = this.viewMode;
- if(e.ctrlKey) {
- viewMode += 2;
- } else if(e.shiftKey) {
- viewMode += 1;
- }
- if(viewMode == 4) {
- newDate = this.moveYear(this.date, dir);
- newViewDate = this.moveYear(this.viewDate, dir);
- } else if(viewMode == 3) {
- newDate = this.moveMonth(this.date, dir);
- newViewDate = this.moveMonth(this.viewDate, dir);
- } else if(viewMode == 2) {
- newDate = this.moveDate(this.date, dir * 7);
- newViewDate = this.moveDate(this.viewDate, dir * 7);
- } else if(viewMode == 1) {
- if(this.showMeridian) {
- newDate = this.moveHour(this.date, dir * 6);
- newViewDate = this.moveHour(this.viewDate, dir * 6);
- } else {
- newDate = this.moveHour(this.date, dir * 4);
- newViewDate = this.moveHour(this.viewDate, dir * 4);
- }
- } else if(viewMode == 0) {
- newDate = this.moveMinute(this.date, dir * 4);
- newViewDate = this.moveMinute(this.viewDate, dir * 4);
- }
- if(this.dateWithinRange(newDate)) {
- this.date = newDate;
- this.viewDate = newViewDate;
- this.setValue();
- this.update();
- e.preventDefault();
- dateChanged = true;
- }
- break;
- case 13: // enter
- if(this.viewMode != 0) {
- var oldViewMode = this.viewMode;
- this.showMode(-1);
- this.fill();
- if(oldViewMode == this.viewMode && this.autoclose) {
- this.hide();
- }
- } else {
- this.fill();
- if(this.autoclose) {
- this.hide();
- }
- }
- e.preventDefault();
- break;
- case 9: // tab
- this.hide();
- break;
- }
- if(dateChanged) {
- var element;
- if(this.isInput) {
- element = this.element;
- } else if(this.component) {
- element = this.element.find('input');
- }
- if(element) {
- element.change();
- }
- this.element.trigger({
- type: 'changeDate',
- date: this.date
- });
- }
- },
-
- showMode: function(dir) {
- if(dir) {
- var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
- if(newViewMode >= this.minView && newViewMode <= this.maxView) {
- this.element.trigger({
- type: 'changeMode',
- date: this.viewDate,
- oldViewMode: this.viewMode,
- newViewMode: newViewMode
- });
-
- this.viewMode = newViewMode;
- }
- }
- /*
- vitalets: fixing bug of very special conditions:
- jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
- Method show() does not set display css correctly and datetimepicker is not shown.
- Changed to .css('display', 'block') solve the problem.
- See https://github.com/vitalets/x-editable/issues/37
-
- In jquery 1.7.2+ everything works fine.
- */
- //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
- this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
- this.updateNavArrows();
- },
-
- reset: function(e) {
- this._setDate(null, 'date');
- }
- };
-
- $.fn.datetimepicker = function(option) {
- var args = Array.apply(null, arguments);
- args.shift();
- return this.each(function() {
- var $this = $(this),
- data = $this.data('datetimepicker'),
- options = typeof option == 'object' && option;
- if(!data) {
- $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({}, $.fn.datetimepicker.defaults, $this.data(), options))));
- }
- if(typeof option == 'string' && typeof data[option] == 'function') {
- data[option].apply(data, args);
- }
- });
- };
-
- $.fn.datetimepicker.defaults = {
- pickerPosition: 'auto-right'
- };
- $.fn.datetimepicker.Constructor = Datetimepicker;
- var dates = $.fn.datetimepicker.dates = {
- en: {
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
- daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
- daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
- monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
- meridiem: ["am", "pm"],
- suffix: ["st", "nd", "rd", "th"],
- today: "Today"
- }
- };
-
- dates['zh-cn'] = {
- days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
- daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
- daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
- months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- today: "今日",
- suffix: [],
- meridiem: []
- };
- dates['zh-tw'] = {
- days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
- daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
- daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
- months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- today: "今天",
- suffix: [],
- meridiem: ["上午", "下午"]
- };
-
- var DPGlobal = {
- modes: [{
- clsName: 'minutes',
- navFnc: 'Hours',
- navStep: 1
- }, {
- clsName: 'hours',
- navFnc: 'Date',
- navStep: 1
- }, {
- clsName: 'days',
- navFnc: 'Month',
- navStep: 1
- }, {
- clsName: 'months',
- navFnc: 'FullYear',
- navStep: 1
- }, {
- clsName: 'years',
- navFnc: 'FullYear',
- navStep: 10
- }],
- isLeapYear: function(year) {
- return(((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
- },
- getDaysInMonth: function(year, month) {
- return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
- },
- getDefaultFormat: function(type, field) {
- if(type == "standard") {
- if(field == 'input')
- return 'yyyy-mm-dd hh:ii';
- else
- return 'yyyy-mm-dd hh:ii:ss';
- } else if(type == "php") {
- if(field == 'input')
- return 'Y-m-d H:i';
- else
- return 'Y-m-d H:i:s';
- } else {
- throw new Error("Invalid format type.");
- }
- },
- validParts: function(type) {
- if(type == "standard") {
- return /hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
- } else if(type == "php") {
- return /[dDjlNwzFmMnStyYaABgGhHis]/g;
- } else {
- throw new Error("Invalid format type.");
- }
- },
- nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
- parseFormat: function(format, type) {
- // IE treats \0 as a string end in inputs (truncating the value),
- // so it's a bad format delimiter, anyway
- var separators = format.replace(this.validParts(type), '\0').split('\0'),
- parts = format.match(this.validParts(type));
- if(!separators || !separators.length || !parts || parts.length == 0) {
- throw new Error("Invalid date format.");
- }
- return {
- separators: separators,
- parts: parts
- };
- },
- parseDate: function(date, format, language, type) {
- if(date instanceof Date) {
- var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
- dateUTC.setMilliseconds(0);
- return dateUTC;
- }
- if(/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
- format = this.parseFormat('yyyy-mm-dd', type);
- }
- if(/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
- format = this.parseFormat('yyyy-mm-dd hh:ii', type);
- }
- if(/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
- format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
- }
- if(/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
- var part_re = /([-+]\d+)([dmwy])/,
- parts = date.match(/([-+]\d+)([dmwy])/g),
- part, dir;
- date = new Date();
- for(var i = 0; i < parts.length; i++) {
- part = part_re.exec(parts[i]);
- dir = parseInt(part[1]);
- switch(part[2]) {
- case 'd':
- date.setUTCDate(date.getUTCDate() + dir);
- break;
- case 'm':
- date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
- break;
- case 'w':
- date.setUTCDate(date.getUTCDate() + dir * 7);
- break;
- case 'y':
- date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
- break;
- }
- }
- return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
- }
- var parts = date && date.match(this.nonpunctuation) || [],
- date = new Date(0, 0, 0, 0, 0, 0, 0),
- parsed = {},
- setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P'],
- setters_map = {
- hh: function(d, v) {
- return d.setUTCHours(v);
- },
- h: function(d, v) {
- return d.setUTCHours(v);
- },
- HH: function(d, v) {
- return d.setUTCHours(v == 12 ? 0 : v);
- },
- H: function(d, v) {
- return d.setUTCHours(v == 12 ? 0 : v);
- },
- ii: function(d, v) {
- return d.setUTCMinutes(v);
- },
- i: function(d, v) {
- return d.setUTCMinutes(v);
- },
- ss: function(d, v) {
- return d.setUTCSeconds(v);
- },
- s: function(d, v) {
- return d.setUTCSeconds(v);
- },
- yyyy: function(d, v) {
- return d.setUTCFullYear(v);
- },
- yy: function(d, v) {
- return d.setUTCFullYear(2000 + v);
- },
- m: function(d, v) {
- v -= 1;
- while(v < 0) v += 12;
- v %= 12;
- d.setUTCMonth(v);
- while(d.getUTCMonth() != v)
- d.setUTCDate(d.getUTCDate() - 1);
- return d;
- },
- d: function(d, v) {
- return d.setUTCDate(v);
- },
- p: function(d, v) {
- return d.setUTCHours(v == 1 ? d.getUTCHours() + 12 : d.getUTCHours());
- }
- },
- val, filtered, part;
- setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
- setters_map['dd'] = setters_map['d'];
- setters_map['P'] = setters_map['p'];
- date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
- if(parts.length == format.parts.length) {
- for(var i = 0, cnt = format.parts.length; i < cnt; i++) {
- val = parseInt(parts[i], 10);
- part = format.parts[i];
- if(isNaN(val)) {
- switch(part) {
- case 'MM':
- filtered = $(dates[language].months).filter(function() {
- var m = this.slice(0, parts[i].length),
- p = parts[i].slice(0, m.length);
- return m == p;
- });
- val = $.inArray(filtered[0], dates[language].months) + 1;
- break;
- case 'M':
- filtered = $(dates[language].monthsShort).filter(function() {
- var m = this.slice(0, parts[i].length),
- p = parts[i].slice(0, m.length);
- return m == p;
- });
- val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
- break;
- case 'p':
- case 'P':
- val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
- break;
- }
- }
- parsed[part] = val;
- }
- for(var i = 0, s; i < setters_order.length; i++) {
- s = setters_order[i];
- if(s in parsed && !isNaN(parsed[s]))
- setters_map[s](date, parsed[s])
- }
- }
- return date;
- },
- formatDate: function(date, format, language, type) {
- if(date == null) {
- return '';
- }
- var val;
- if(type == 'standard') {
- val = {
- // year
- yy: date.getUTCFullYear().toString().substring(2),
- yyyy: date.getUTCFullYear(),
- // month
- m: date.getUTCMonth() + 1,
- M: dates[language].monthsShort[date.getUTCMonth()],
- MM: dates[language].months[date.getUTCMonth()],
- // day
- d: date.getUTCDate(),
- D: dates[language].daysShort[date.getUTCDay()],
- DD: dates[language].days[date.getUTCDay()],
- p: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
- // hour
- h: date.getUTCHours(),
- // minute
- i: date.getUTCMinutes(),
- // second
- s: date.getUTCSeconds()
- };
-
- if(dates[language].meridiem.length == 2) {
- val.H = (val.h % 12 == 0 ? 12 : val.h % 12);
- } else {
- val.H = val.h;
- }
- val.HH = (val.H < 10 ? '0' : '') + val.H;
- val.P = val.p.toUpperCase();
- val.hh = (val.h < 10 ? '0' : '') + val.h;
- val.ii = (val.i < 10 ? '0' : '') + val.i;
- val.ss = (val.s < 10 ? '0' : '') + val.s;
- val.dd = (val.d < 10 ? '0' : '') + val.d;
- val.mm = (val.m < 10 ? '0' : '') + val.m;
- } else if(type == 'php') {
- // php format
- val = {
- // year
- y: date.getUTCFullYear().toString().substring(2),
- Y: date.getUTCFullYear(),
- // month
- F: dates[language].months[date.getUTCMonth()],
- M: dates[language].monthsShort[date.getUTCMonth()],
- n: date.getUTCMonth() + 1,
- t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
- // day
- j: date.getUTCDate(),
- l: dates[language].days[date.getUTCDay()],
- D: dates[language].daysShort[date.getUTCDay()],
- w: date.getUTCDay(), // 0 -> 6
- N: (date.getUTCDay() == 0 ? 7 : date.getUTCDay()), // 1 -> 7
- S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
- // hour
- a: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
- g: (date.getUTCHours() % 12 == 0 ? 12 : date.getUTCHours() % 12),
- G: date.getUTCHours(),
- // minute
- i: date.getUTCMinutes(),
- // second
- s: date.getUTCSeconds()
- };
- val.m = (val.n < 10 ? '0' : '') + val.n;
- val.d = (val.j < 10 ? '0' : '') + val.j;
- val.A = val.a.toString().toUpperCase();
- val.h = (val.g < 10 ? '0' : '') + val.g;
- val.H = (val.G < 10 ? '0' : '') + val.G;
- val.i = (val.i < 10 ? '0' : '') + val.i;
- val.s = (val.s < 10 ? '0' : '') + val.s;
- } else {
- throw new Error("Invalid format type.");
- }
- var date = [],
- seps = $.extend([], format.separators);
- for(var i = 0, cnt = format.parts.length; i < cnt; i++) {
- if(seps.length) {
- date.push(seps.shift());
- }
- date.push(val[format.parts[i]]);
- }
- if(seps.length) {
- date.push(seps.shift());
- }
- return date.join('');
- },
- convertViewMode: function(viewMode) {
- switch(viewMode) {
- case 4:
- case 'decade':
- viewMode = 4;
- break;
- case 3:
- case 'year':
- viewMode = 3;
- break;
- case 2:
- case 'month':
- viewMode = 2;
- break;
- case 1:
- case 'day':
- viewMode = 1;
- break;
- case 0:
- case 'hour':
- viewMode = 0;
- break;
- }
-
- return viewMode;
- },
- headTemplate: '' +
- '' +
- ' | ' +
- ' | ' +
- ' | ' +
- ' ' +
- '',
- contTemplate: ' | ',
- footTemplate: ' | '
- };
- DPGlobal.template = '' +
- ' ' +
- ' ' +
- DPGlobal.headTemplate +
- DPGlobal.contTemplate +
- DPGlobal.footTemplate +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- DPGlobal.headTemplate +
- DPGlobal.contTemplate +
- DPGlobal.footTemplate +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- DPGlobal.headTemplate +
- '' +
- DPGlobal.footTemplate +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- DPGlobal.headTemplate +
- DPGlobal.contTemplate +
- DPGlobal.footTemplate +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- DPGlobal.headTemplate +
- DPGlobal.contTemplate +
- DPGlobal.footTemplate +
- ' ' +
- ' ' +
- ' ';
- $.fn.datetimepicker.DPGlobal = DPGlobal;
-
- /* DATETIMEPICKER NO CONFLICT
- * =================== */
-
- $.fn.datetimepicker.noConflict = function() {
- $.fn.datetimepicker = old;
- return this;
- };
-
- /* DATETIMEPICKER DATA-API
- * ================== */
-
- $(document).on(
- 'focus.datetimepicker.data-api click.datetimepicker.data-api',
- '[data-provide="datetimepicker"]',
- function(e) {
- var $this = $(this);
- if($this.data('datetimepicker')) return;
- e.preventDefault();
- // component click requires us to explicitly show it
- $this.datetimepicker('show');
- }
- );
- $(function() {
- $('[data-provide="datetimepicker-inline"]').datetimepicker();
- });
-
-}(window.jQuery);
-
-
-/* ========================================================================
- * Chosen: chosen.js [version 1.1.0]
- * https://github.com/harvesthq/chosen
- *
- * Chosen, a Select Box Enhancer for jQuery and Prototype
- * by Patrick Filler for Harvest, http://getharvest.com
- *
- * ZUI: The file has been changed in ZUI. It will not keep update with the
- * official version in the future.
- * http://zui.sexy
- * ========================================================================
- * Copyright (c) 2011 Harvest http://getharvest.com
- * MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
- * ========================================================================
- * Improvement in ZUI:
- * 1. New option 'drop_direction': 'auto' | 'top' | 'bottom';
- * 2. Enhance the search experience, support search items by custom data
- * with 'data-keys=*' attribute in option;
- * 3. ‘middle_highlight’ option can make hightlight item in the middle of
- * the dropdown menu
- * ======================================================================== */
-
-
-/*!
+!function(t){function e(){return new Date(Date.UTC.apply(Date,arguments))}var i=function(e,i){var a=this;this.element=t(e),this.language=(i.language||this.element.data("date-language")||(t.zui&&t.zui.clientLang?t.zui.clientLang().replace("_","-"):"zh-cn")).toLowerCase(),this.language=this.language in s?this.language:"en",this.isRTL=s[this.language].rtl||!1,this.formatType=i.formatType||this.element.data("format-type")||"standard",this.format=n.parseFormat(i.format||this.element.data("date-format")||s[this.language].format||n.getDefaultFormat(this.formatType,"input"),this.formatType),this.isInline=!1,this.isVisible=!1,this.isInput=this.element.is("input"),this.component=!!this.element.is(".date")&&this.element.find(".input-group-addon .icon-th, .input-group-addon .icon-time, .input-group-addon .icon-calendar").parent(),this.componentReset=!!this.element.is(".date")&&this.element.find(".input-group-addon .icon-remove").parent(),this.hasInput=this.component&&this.element.find("input").length,this.component&&0===this.component.length&&(this.component=!1),this.linkField=i.linkField||this.element.data("link-field")||!1,this.linkFormat=n.parseFormat(i.linkFormat||this.element.data("link-format")||n.getDefaultFormat(this.formatType,"link"),this.formatType),this.minuteStep=i.minuteStep||this.element.data("minute-step")||5,this.pickerPosition=i.pickerPosition||this.element.data("picker-position")||"bottom-right",this.showMeridian=i.showMeridian||this.element.data("show-meridian")||!1,this.initialDate=i.initialDate||new Date,this.pickerClass=i.eleClass,this.pickerId=i.eleId,this._attachEvents(),this.formatViewType="datetime","formatViewType"in i?this.formatViewType=i.formatViewType:"formatViewType"in this.element.data()&&(this.formatViewType=this.element.data("formatViewType")),this.minView=0,"minView"in i?this.minView=i.minView:"minView"in this.element.data()&&(this.minView=this.element.data("min-view")),this.minView=n.convertViewMode(this.minView),this.maxView=n.modes.length-1,"maxView"in i?this.maxView=i.maxView:"maxView"in this.element.data()&&(this.maxView=this.element.data("max-view")),this.maxView=n.convertViewMode(this.maxView),this.wheelViewModeNavigation=!1,"wheelViewModeNavigation"in i?this.wheelViewModeNavigation=i.wheelViewModeNavigation:"wheelViewModeNavigation"in this.element.data()&&(this.wheelViewModeNavigation=this.element.data("view-mode-wheel-navigation")),this.wheelViewModeNavigationInverseDirection=!1,"wheelViewModeNavigationInverseDirection"in i?this.wheelViewModeNavigationInverseDirection=i.wheelViewModeNavigationInverseDirection:"wheelViewModeNavigationInverseDirection"in this.element.data()&&(this.wheelViewModeNavigationInverseDirection=this.element.data("view-mode-wheel-navigation-inverse-dir")),this.wheelViewModeNavigationDelay=100,"wheelViewModeNavigationDelay"in i?this.wheelViewModeNavigationDelay=i.wheelViewModeNavigationDelay:"wheelViewModeNavigationDelay"in this.element.data()&&(this.wheelViewModeNavigationDelay=this.element.data("view-mode-wheel-navigation-delay")),this.startViewMode=2,"startView"in i?this.startViewMode=i.startView:"startView"in this.element.data()&&(this.startViewMode=this.element.data("start-view")),this.startViewMode=n.convertViewMode(this.startViewMode),this.viewMode=this.startViewMode,this.viewSelect=this.minView,"viewSelect"in i?this.viewSelect=i.viewSelect:"viewSelect"in this.element.data()&&(this.viewSelect=this.element.data("view-select")),this.viewSelect=n.convertViewMode(this.viewSelect),this.forceParse=!0,"forceParse"in i?this.forceParse=i.forceParse:"dateForceParse"in this.element.data()&&(this.forceParse=this.element.data("date-force-parse")),this.picker=t(n.template).appendTo(this.isInline?this.element:"body").on({click:t.proxy(this.click,this),mousedown:t.proxy(this.mousedown,this)}),this.wheelViewModeNavigation&&(t.fn.mousewheel?this.picker.on({mousewheel:t.proxy(this.mousewheel,this)}):console.log("Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option")),this.isInline?this.picker.addClass("datetimepicker-inline"):this.picker.addClass("datetimepicker-dropdown-"+this.pickerPosition+" dropdown-menu"),this.isRTL&&(this.picker.addClass("datetimepicker-rtl"),this.picker.find(".prev span, .next span").toggleClass("icon-arrow-left icon-arrow-right")),t(document).on("mousedown",function(e){0===t(e.target).closest(".datetimepicker").length&&a.hide()}),this.autoclose=!1,"autoclose"in i?this.autoclose=i.autoclose:"dateAutoclose"in this.element.data()&&(this.autoclose=this.element.data("date-autoclose")),this.keyboardNavigation=!0,"keyboardNavigation"in i?this.keyboardNavigation=i.keyboardNavigation:"dateKeyboardNavigation"in this.element.data()&&(this.keyboardNavigation=this.element.data("date-keyboard-navigation")),this.todayBtn=i.todayBtn||this.element.data("date-today-btn")||!1,this.todayHighlight=i.todayHighlight||this.element.data("date-today-highlight")||!1,this.weekStart=(i.weekStart||this.element.data("date-weekstart")||s[this.language].weekStart||0)%7,this.weekEnd=(this.weekStart+6)%7,this.startDate=-(1/0),this.endDate=1/0,this.daysOfWeekDisabled=[],this.setStartDate(i.startDate||this.element.data("date-startdate")),this.setEndDate(i.endDate||this.element.data("date-enddate")),this.setDaysOfWeekDisabled(i.daysOfWeekDisabled||this.element.data("date-days-of-week-disabled")),this.fillDow(),this.fillMonths(),this.update(),this.showMode(),this.isInline&&this.show()};i.prototype={constructor:i,_events:[],_attachEvents:function(){this._detachEvents(),this.isInput?this._events=[[this.element,{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}]]:this.component&&this.hasInput?(this._events=[[this.element.find("input"),{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}],[this.component,{click:t.proxy(this.show,this)}]],this.componentReset&&this._events.push([this.componentReset,{click:t.proxy(this.reset,this)}])):this.element.is("div")?this.isInline=!0:this._events=[[this.element,{click:t.proxy(this.show,this)}]];for(var e,i,s=0;s=this.startDate&&t<=this.endDate?(this.date=t,this.setValue(),this.viewDate=this.date,this.fill()):this.element.trigger({type:"outOfRange",date:t,startDate:this.startDate,endDate:this.endDate})},setFormat:function(t){this.format=n.parseFormat(t,this.formatType);var e;this.isInput?e=this.element:this.component&&(e=this.element.find("input")),e&&e.val()&&this.setValue()},setValue:function(){var e=this.getFormattedDate();this.isInput?this.element.val(e):(this.component&&this.element.find("input").val(e),this.element.data("date",e)),this.linkField&&t("#"+this.linkField).val(this.getFormattedDate(this.linkFormat))},getFormattedDate:function(t){return void 0==t&&(t=this.format),n.formatDate(this.date,t,this.language,this.formatType)},setStartDate:function(t){this.startDate=t||-(1/0),this.startDate!==-(1/0)&&(this.startDate=n.parseDate(this.startDate,this.format,this.language,this.formatType)),this.update(),this.updateNavArrows()},setEndDate:function(t){this.endDate=t||1/0,this.endDate!==1/0&&(this.endDate=n.parseDate(this.endDate,this.format,this.language,this.formatType)),this.update(),this.updateNavArrows()},setDaysOfWeekDisabled:function(e){this.daysOfWeekDisabled=e||[],t.isArray(this.daysOfWeekDisabled)||(this.daysOfWeekDisabled=this.daysOfWeekDisabled.split(/,\s*/)),this.daysOfWeekDisabled=t.map(this.daysOfWeekDisabled,function(t){return parseInt(t,10)}),this.update(),this.updateNavArrows()},place:function(){if(!this.isInline){var e=0;t("div").each(function(){var i=parseInt(t(this).css("zIndex"),10);i>e&&(e=i)});var i,s,n,a=e+10;this.component?(i=this.component.offset(),n=i.left,"bottom-left"!==this.pickerPosition&&"top-left"!==this.pickerPosition&&"auto-left"!==this.pickerPosition||(n+=this.component.outerWidth()-this.picker.outerWidth())):(i=this.element.offset(),n=i.left);var o=0===this.pickerPosition.indexOf("auto-"),r=o?(i.top+this.picker.outerHeight()>t(window).height()+t(window).scrollTop()?"top":"bottom")+(0===this.pickerPosition.lastIndexOf("-left")?"-left":"-right"):this.pickerPosition;s="top-left"===r||"top-right"===r?i.top-this.picker.outerHeight():i.top+this.height,this.picker.css({top:s,left:n,zIndex:a}).attr("class","datetimepicker dropdown-menu datetimepicker-dropdown-"+r),this.pickerClass&&this.picker.addClass(this.pickerClass),this.pickerId&&this.picker.attr("id",this.pickerId)}},update:function(){var t,e=!1;arguments&&arguments.length&&("string"==typeof arguments[0]||arguments[0]instanceof Date)?(t=arguments[0],e=!0):(t=this.element.data("date")||(this.isInput?this.element.val():this.element.find("input").val())||this.initialDate,("string"==typeof t||t instanceof String)&&(t=t.replace(/^\s+|\s+$/g,""))),t||(t=new Date,e=!1),this.date=n.parseDate(t,this.format,this.language,this.formatType),e&&this.setValue(),this.datethis.endDate?this.viewDate=new Date(this.endDate):this.viewDate=new Date(this.date),this.fill()},fillDow:function(){for(var t=this.weekStart,e="";t'+s[this.language].daysMin[t++%7]+"";e+=" ",this.picker.find(".datetimepicker-days thead").append(e)},fillMonths:function(){for(var t="",e=0;e<12;)t+=''+s[this.language].monthsShort[e++]+"";this.picker.find(".datetimepicker-months td").html(t)},fill:function(){if(null!=this.date&&null!=this.viewDate){var i=new Date(this.viewDate),a=i.getUTCFullYear(),o=i.getUTCMonth(),r=i.getUTCDate(),l=i.getUTCHours(),h=i.getUTCMinutes(),c=this.startDate!==-(1/0)?this.startDate.getUTCFullYear():-(1/0),d=this.startDate!==-(1/0)?this.startDate.getUTCMonth():-(1/0),u=this.endDate!==1/0?this.endDate.getUTCFullYear():1/0,p=this.endDate!==1/0?this.endDate.getUTCMonth():1/0,f=new e(this.date.getUTCFullYear(),this.date.getUTCMonth(),this.date.getUTCDate()).valueOf(),g=new Date;if(this.picker.find(".datetimepicker-days thead th:eq(1)").text(s[this.language].months[o]+" "+a),"time"==this.formatViewType){var m=l%12?l%12:12,v=(m<10?"0":"")+m,y=(h<10?"0":"")+h,b=s[this.language].meridiem[l<12?0:1];this.picker.find(".datetimepicker-hours thead th:eq(1)").text(v+":"+y+" "+b.toUpperCase()),this.picker.find(".datetimepicker-minutes thead th:eq(1)").text(v+":"+y+" "+b.toUpperCase())}else this.picker.find(".datetimepicker-hours thead th:eq(1)").text(r+" "+s[this.language].months[o]+" "+a),this.picker.find(".datetimepicker-minutes thead th:eq(1)").text(r+" "+s[this.language].months[o]+" "+a);this.picker.find("tfoot th.today").text(s[this.language].today).toggle(this.todayBtn!==!1),this.updateNavArrows(),this.fillMonths();var w=e(a,o-1,28,0,0,0,0),x=n.getDaysInMonth(w.getUTCFullYear(),w.getUTCMonth());w.setUTCDate(x),w.setUTCDate(x-(w.getUTCDay()-this.weekStart+7)%7);var _=new Date(w);_.setUTCDate(_.getUTCDate()+42),_=_.valueOf();for(var C,k=[];w.valueOf()<_;)w.getUTCDay()==this.weekStart&&k.push(""),C="",w.getUTCFullYear()a||w.getUTCFullYear()==a&&w.getUTCMonth()>o)&&(C+=" new"),this.todayHighlight&&w.getUTCFullYear()==g.getFullYear()&&w.getUTCMonth()==g.getMonth()&&w.getUTCDate()==g.getDate()&&(C+=" today"),w.valueOf()==f&&(C+=" active"),(w.valueOf()+864e5<=this.startDate||w.valueOf()>this.endDate||t.inArray(w.getUTCDay(),this.daysOfWeekDisabled)!==-1)&&(C+=" disabled"),k.push('| '+w.getUTCDate()+" | "),w.getUTCDay()==this.weekEnd&&k.push(" "),w.setUTCDate(w.getUTCDate()+1);this.picker.find(".datetimepicker-days tbody").empty().append(k.join("")),k=[];for(var T="",S="",D="",M=0;M<24;M++){var P=e(a,o,r,M);C="",P.valueOf()+36e5<=this.startDate||P.valueOf()>this.endDate?C+=" disabled":l==M&&(C+=" active"),this.showMeridian&&2==s[this.language].meridiem.length?(S=M<12?s[this.language].meridiem[0]:s[this.language].meridiem[1],S!=D&&(""!=D&&k.push(""),k.push('")):(T=M+":00",k.push(''+T+""))}this.picker.find(".datetimepicker-hours td").html(k.join("")),k=[],T="",S="",D="";for(var M=0;M<60;M+=this.minuteStep){var P=e(a,o,r,l,M,0);C="",P.valueOf()this.endDate?C+=" disabled":Math.floor(h/this.minuteStep)==Math.floor(M/this.minuteStep)&&(C+=" active"),this.showMeridian&&2==s[this.language].meridiem.length?(S=l<12?s[this.language].meridiem[0]:s[this.language].meridiem[1],S!=D&&(""!=D&&k.push(""),k.push('")):(T=M+":00",k.push(''+l+":"+(M<10?"0"+M:M)+""))}this.picker.find(".datetimepicker-minutes td").html(k.join(""));var F=this.date.getUTCFullYear(),L=this.picker.find(".datetimepicker-months").find("th:eq(1)").text(a).end().find("span").removeClass("active");F==a&&L.eq(this.date.getUTCMonth()).addClass("active"),(au)&&L.addClass("disabled"),a==c&&L.slice(0,d).addClass("disabled"),a==u&&L.slice(p+1).addClass("disabled"),k="",a=10*parseInt(a/10,10);var z=this.picker.find(".datetimepicker-years").find("th:eq(1)").text(a+"-"+(a+9)).end().find("td");a-=1;for(var M=-1;M<11;M++)k+='u?" disabled":"")+'">'+a+"",a+=1;z.html(k),this.place()}},updateNavArrows:function(){var t=new Date(this.viewDate),e=t.getUTCFullYear(),i=t.getUTCMonth(),s=t.getUTCDate(),n=t.getUTCHours();switch(this.viewMode){case 0:this.startDate!==-(1/0)&&e<=this.startDate.getUTCFullYear()&&i<=this.startDate.getUTCMonth()&&s<=this.startDate.getUTCDate()&&n<=this.startDate.getUTCHours()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.endDate!==1/0&&e>=this.endDate.getUTCFullYear()&&i>=this.endDate.getUTCMonth()&&s>=this.endDate.getUTCDate()&&n>=this.endDate.getUTCHours()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 1:this.startDate!==-(1/0)&&e<=this.startDate.getUTCFullYear()&&i<=this.startDate.getUTCMonth()&&s<=this.startDate.getUTCDate()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.endDate!==1/0&&e>=this.endDate.getUTCFullYear()&&i>=this.endDate.getUTCMonth()&&s>=this.endDate.getUTCDate()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 2:this.startDate!==-(1/0)&&e<=this.startDate.getUTCFullYear()&&i<=this.startDate.getUTCMonth()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.endDate!==1/0&&e>=this.endDate.getUTCFullYear()&&i>=this.endDate.getUTCMonth()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 3:case 4:this.startDate!==-(1/0)&&e<=this.startDate.getUTCFullYear()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),this.endDate!==1/0&&e>=this.endDate.getUTCFullYear()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"})}},mousewheel:function(e){if(e.preventDefault(),e.stopPropagation(),!this.wheelPause){this.wheelPause=!0;var i=e.originalEvent,s=i.wheelDelta,n=s>0?1:0===s?0:-1;this.wheelViewModeNavigationInverseDirection&&(n=-n),this.showMode(n),setTimeout(t.proxy(function(){this.wheelPause=!1},this),this.wheelViewModeNavigationDelay)}},click:function(i){i.stopPropagation(),i.preventDefault();var s=t(i.target).closest("span, td, th, legend");if(1==s.length){if(s.is(".disabled"))return void this.element.trigger({type:"outOfRange",date:this.viewDate,startDate:this.startDate,endDate:this.endDate});switch(s[0].nodeName.toLowerCase()){case"th":switch(s[0].className){case"switch":this.showMode(1);break;case"prev":case"next":var a=n.modes[this.viewMode].navStep*("prev"==s[0].className?-1:1);switch(this.viewMode){case 0:this.viewDate=this.moveHour(this.viewDate,a);break;case 1:this.viewDate=this.moveDate(this.viewDate,a);break;case 2:this.viewDate=this.moveMonth(this.viewDate,a);break;case 3:case 4:this.viewDate=this.moveYear(this.viewDate,a)}this.fill();break;case"today":var o=new Date;o=e(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),o.getMinutes(),o.getSeconds(),0),othis.endDate&&(o=this.endDate),this.viewMode=this.startViewMode,this.showMode(0),this._setDate(o),this.fill(),this.autoclose&&this.hide()}break;case"span":if(!s.is(".disabled")){var r=this.viewDate.getUTCFullYear(),l=this.viewDate.getUTCMonth(),h=this.viewDate.getUTCDate(),c=this.viewDate.getUTCHours(),d=this.viewDate.getUTCMinutes(),u=this.viewDate.getUTCSeconds();if(s.is(".month")?(this.viewDate.setUTCDate(1),l=s.parent().find("span").index(s),h=this.viewDate.getUTCDate(),this.viewDate.setUTCMonth(l),this.element.trigger({type:"changeMonth",date:this.viewDate}),this.viewSelect>=3&&this._setDate(e(r,l,h,c,d,u,0))):s.is(".year")?(this.viewDate.setUTCDate(1),r=parseInt(s.text(),10)||0,this.viewDate.setUTCFullYear(r),this.element.trigger({type:"changeYear",date:this.viewDate}),this.viewSelect>=4&&this._setDate(e(r,l,h,c,d,u,0))):s.is(".hour")?(c=parseInt(s.text(),10)||0,(s.hasClass("hour_am")||s.hasClass("hour_pm"))&&(12==c&&s.hasClass("hour_am")?c=0:12!=c&&s.hasClass("hour_pm")&&(c+=12)),this.viewDate.setUTCHours(c),this.element.trigger({type:"changeHour",date:this.viewDate}),this.viewSelect>=1&&this._setDate(e(r,l,h,c,d,u,0))):s.is(".minute")&&(d=parseInt(s.text().substr(s.text().indexOf(":")+1),10)||0,this.viewDate.setUTCMinutes(d),this.element.trigger({type:"changeMinute",date:this.viewDate}),this.viewSelect>=0&&this._setDate(e(r,l,h,c,d,u,0))),0!=this.viewMode){var p=this.viewMode;this.showMode(-1),this.fill(),p==this.viewMode&&this.autoclose&&this.hide()}else this.fill(),this.autoclose&&this.hide()}break;case"td":if(s.is(".day")&&!s.is(".disabled")){var h=parseInt(s.text(),10)||1,r=this.viewDate.getUTCFullYear(),l=this.viewDate.getUTCMonth(),c=this.viewDate.getUTCHours(),d=this.viewDate.getUTCMinutes(),u=this.viewDate.getUTCSeconds();s.is(".old")?0===l?(l=11,r-=1):l-=1:s.is(".new")&&(11==l?(l=0,r+=1):l+=1),this.viewDate.setUTCFullYear(r),this.viewDate.setUTCMonth(l,h),this.element.trigger({type:"changeDay",date:this.viewDate}),this.viewSelect>=2&&this._setDate(e(r,l,h,c,d,u,0))}var p=this.viewMode;this.showMode(-1),this.fill(),p==this.viewMode&&this.autoclose&&this.hide()}}},_setDate:function(t,e){e&&"date"!=e||(this.date=t),e&&"view"!=e||(this.viewDate=t),this.fill(),this.setValue();var i;this.isInput?i=this.element:this.component&&(i=this.element.find("input")),i&&(i.change(),this.autoclose&&(!e||"date"==e)),this.element.trigger({type:"changeDate",date:this.date}),null===t&&(this.date=this.viewDate)},moveMinute:function(t,e){if(!e)return t;var i=new Date(t.valueOf());return i.setUTCMinutes(i.getUTCMinutes()+e*this.minuteStep),i},moveHour:function(t,e){if(!e)return t;var i=new Date(t.valueOf());return i.setUTCHours(i.getUTCHours()+e),i},moveDate:function(t,e){if(!e)return t;var i=new Date(t.valueOf());return i.setUTCDate(i.getUTCDate()+e),i},moveMonth:function(t,e){if(!e)return t;var i,s,n=new Date(t.valueOf()),a=n.getUTCDate(),o=n.getUTCMonth(),r=Math.abs(e);if(e=e>0?1:-1,1==r)s=e==-1?function(){return n.getUTCMonth()==o}:function(){return n.getUTCMonth()!=i},i=o+e,n.setUTCMonth(i),(i<0||i>11)&&(i=(i+12)%12);else{for(var l=0;l=this.startDate&&t<=this.endDate},keydown:function(t){if(this.picker.is(":not(:visible)"))return void(27==t.keyCode&&this.show());var e,i,s,n=!1;switch(t.keyCode){case 27:this.hide(),t.preventDefault();break;case 37:case 39:if(!this.keyboardNavigation)break;e=37==t.keyCode?-1:1,viewMode=this.viewMode,t.ctrlKey?viewMode+=2:t.shiftKey&&(viewMode+=1),4==viewMode?(i=this.moveYear(this.date,e),s=this.moveYear(this.viewDate,e)):3==viewMode?(i=this.moveMonth(this.date,e),s=this.moveMonth(this.viewDate,e)):2==viewMode?(i=this.moveDate(this.date,e),s=this.moveDate(this.viewDate,e)):1==viewMode?(i=this.moveHour(this.date,e),s=this.moveHour(this.viewDate,e)):0==viewMode&&(i=this.moveMinute(this.date,e),s=this.moveMinute(this.viewDate,e)),this.dateWithinRange(i)&&(this.date=i,this.viewDate=s,this.setValue(),this.update(),t.preventDefault(),n=!0);break;case 38:case 40:if(!this.keyboardNavigation)break;e=38==t.keyCode?-1:1,viewMode=this.viewMode,t.ctrlKey?viewMode+=2:t.shiftKey&&(viewMode+=1),4==viewMode?(i=this.moveYear(this.date,e),s=this.moveYear(this.viewDate,e)):3==viewMode?(i=this.moveMonth(this.date,e),s=this.moveMonth(this.viewDate,e)):2==viewMode?(i=this.moveDate(this.date,7*e),s=this.moveDate(this.viewDate,7*e)):1==viewMode?this.showMeridian?(i=this.moveHour(this.date,6*e),s=this.moveHour(this.viewDate,6*e)):(i=this.moveHour(this.date,4*e),s=this.moveHour(this.viewDate,4*e)):0==viewMode&&(i=this.moveMinute(this.date,4*e),s=this.moveMinute(this.viewDate,4*e)),this.dateWithinRange(i)&&(this.date=i,this.viewDate=s,this.setValue(),this.update(),t.preventDefault(),n=!0);break;case 13:if(0!=this.viewMode){var a=this.viewMode;this.showMode(-1),this.fill(),a==this.viewMode&&this.autoclose&&this.hide()}else this.fill(),this.autoclose&&this.hide();t.preventDefault();break;case 9:this.hide()}if(n){var o;this.isInput?o=this.element:this.component&&(o=this.element.find("input")),o&&o.change(),this.element.trigger({type:"changeDate",date:this.date})}},showMode:function(t){if(t){var e=Math.max(0,Math.min(n.modes.length-1,this.viewMode+t));e>=this.minView&&e<=this.maxView&&(this.element.trigger({type:"changeMode",date:this.viewDate,oldViewMode:this.viewMode,newViewMode:e}),this.viewMode=e)}this.picker.find(">div").hide().filter(".datetimepicker-"+n.modes[this.viewMode].clsName).css("display","block"),this.updateNavArrows()},reset:function(t){this._setDate(null,"date")}},t.fn.datetimepicker=function(e){var s=Array.apply(null,arguments);return s.shift(),this.each(function(){var n=t(this),a=n.data("datetimepicker"),o="object"==typeof e&&e;a||n.data("datetimepicker",a=new i(this,t.extend({},t.fn.datetimepicker.defaults,n.data(),o))),"string"==typeof e&&"function"==typeof a[e]&&a[e].apply(a,s)})},t.fn.datetimepicker.defaults={pickerPosition:"auto-right"},t.fn.datetimepicker.Constructor=i;var s=t.fn.datetimepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["am","pm"],suffix:["st","nd","rd","th"],today:"Today"}};s["zh-cn"]={days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日"],daysShort:["周日","周一","周二","周三","周四","周五","周六","周日"],daysMin:["日","一","二","三","四","五","六","日"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],today:"今日",suffix:[],meridiem:[]},s["zh-tw"]={days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日"],daysShort:["周日","周一","周二","周三","周四","周五","周六","周日"],daysMin:["日","一","二","三","四","五","六","日"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],today:"今天",suffix:[],meridiem:["上午","下午"]};var n={modes:[{clsName:"minutes",navFnc:"Hours",navStep:1},{clsName:"hours",navFnc:"Date",navStep:1},{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(t){return t%4===0&&t%100!==0||t%400===0},getDaysInMonth:function(t,e){return[31,n.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},getDefaultFormat:function(t,e){if("standard"==t)return"input"==e?"yyyy-mm-dd hh:ii":"yyyy-mm-dd hh:ii:ss";if("php"==t)return"input"==e?"Y-m-d H:i":"Y-m-d H:i:s";throw new Error("Invalid format type.")},validParts:function(t){if("standard"==t)return/hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;if("php"==t)return/[dDjlNwzFmMnStyYaABgGhHis]/g;throw new Error("Invalid format type.")},nonpunctuation:/[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,parseFormat:function(t,e){var i=t.replace(this.validParts(e),"\0").split("\0"),s=t.match(this.validParts(e));if(!i||!i.length||!s||0==s.length)throw new Error("Invalid date format.");return{separators:i,parts:s}},parseDate:function(n,a,o,r){if(n instanceof Date){var l=new Date(n.valueOf()-6e4*n.getTimezoneOffset());return l.setMilliseconds(0),l}if(/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(n)&&(a=this.parseFormat("yyyy-mm-dd",r)),/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(n)&&(a=this.parseFormat("yyyy-mm-dd hh:ii",r)),/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(n)&&(a=this.parseFormat("yyyy-mm-dd hh:ii:ss",r)),/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(n)){var h,c,d=/([-+]\d+)([dmwy])/,u=n.match(/([-+]\d+)([dmwy])/g);n=new Date;for(var p=0;p | | |
|---|
|