后端文件更新
This commit is contained in:
@@ -23,9 +23,9 @@ class Client extends Admin{
|
|||||||
'query' => $this->request->param()
|
'query' => $this->request->param()
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = $res->toArray();
|
$data['list'] = $res;
|
||||||
$data['page'] = $res->render();
|
$data['page'] = $res->render();
|
||||||
$this->data = $data;
|
$this->data['data'] = $data;
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,16 @@ class Config extends Admin {
|
|||||||
*/
|
*/
|
||||||
public function group(ConfigModel $config) {
|
public function group(ConfigModel $config) {
|
||||||
if ($this->request->isAjax()) {
|
if ($this->request->isAjax()) {
|
||||||
|
$data = $this->request->param();
|
||||||
|
$result = $config->updateConfig($data);
|
||||||
|
|
||||||
|
if (false !== $result) {
|
||||||
|
$this->data['code'] = 0;
|
||||||
|
$this->data['msg'] = "更新成功!";
|
||||||
|
}else{
|
||||||
$this->data['code'] = 1;
|
$this->data['code'] = 1;
|
||||||
|
$this->data['msg'] = $config->error;
|
||||||
|
}
|
||||||
return $this->data;
|
return $this->data;
|
||||||
} else {
|
} else {
|
||||||
$id = $this->request->param('id', 1);
|
$id = $this->request->param('id', 1);
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
namespace app\model;
|
namespace app\model;
|
||||||
|
|
||||||
use think\Model;
|
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置模型
|
* 设置模型
|
||||||
@@ -46,6 +46,18 @@ class Config extends Model{
|
|||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateConfig($data) {
|
||||||
|
if (empty($data['config'])) {
|
||||||
|
$this->error = "无更新";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($data['config'] as $key => $value) {
|
||||||
|
self::update(['value' => $value], ['name' => $key], ['value']);
|
||||||
|
}
|
||||||
|
Cache::set('system_config', null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据配置类型解析配置
|
* 根据配置类型解析配置
|
||||||
* @param integer $type 配置类型
|
* @param integer $type 配置类型
|
||||||
@@ -88,7 +100,7 @@ class Config extends Model{
|
|||||||
if (!in_array($filename, array('.', '..'))) {
|
if (!in_array($filename, array('.', '..'))) {
|
||||||
$files = $path . $filename . '/info.php';
|
$files = $path . $filename . '/info.php';
|
||||||
if (is_file($files)) {
|
if (is_file($files)) {
|
||||||
$info = include($files);
|
$info = include $files;
|
||||||
if (isset($info['type']) && $info['type'] == $type) {
|
if (isset($info['type']) && $info['type'] == $type) {
|
||||||
$info['id'] = $filename;
|
$info['id'] = $filename;
|
||||||
$info['img'] = '/template/' . $filename . '/' . $info['img'];
|
$info['img'] = '/template/' . $filename . '/' . $info['img'];
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ namespace app\model;
|
|||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
class Content extends Model
|
class Content extends Model {
|
||||||
{
|
// 定义默认的表后缀(默认查询中文数据)
|
||||||
|
protected $suffix = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,17 @@
|
|||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
|
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>SentCMS后台管理系统-{$meta['title']|default="后台首页"}</title>
|
<title>SentCMS后台管理系统-{$meta_title|default="后台首页"}</title>
|
||||||
<link href="__static__/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
<link href="__static__/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
||||||
<link href="__static__/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
<link href="__static__/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
||||||
<link rel="stylesheet" href="__static__/libs/nanoscroller/nanoscroller.css" />
|
<link rel="stylesheet" href="__static__/libs/nanoscroller/nanoscroller.css" />
|
||||||
|
<link rel="stylesheet" href="__static__/libs/hopscotch/hopscotch.css" />
|
||||||
<link href="__css__/theme_styles.css" rel="stylesheet"/>
|
<link href="__css__/theme_styles.css" rel="stylesheet"/>
|
||||||
{block name="style"}{/block}
|
{block name="style"}{/block}
|
||||||
</meta>
|
</meta>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="theme-wrapper" class="vue-main">
|
<div id="theme-wrapper">
|
||||||
<header class="navbar" id="header-navbar">
|
<header class="navbar" id="header-navbar">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
@@ -23,38 +24,36 @@
|
|||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="{:url('admin/index/index')}" id="logo">
|
<a href="{:url('/admin/index/index')}" id="logo" class="navbar-brand">
|
||||||
<img alt="" class="normal-logo logo-white" src="__static__/images/logo.png"/>
|
<img src="__static__/images/logo.png" alt="" class="normal-logo logo-white"/>
|
||||||
<img alt="" class="normal-logo logo-black" src="__static__/images/logo.png"/>
|
|
||||||
<img alt="" class="small-logo hidden-xs hidden-sm hidden" src="__static__/images/logo.png"/>
|
|
||||||
</a>
|
</a>
|
||||||
<ul class="nav navbar-nav pull-right visible-xs">
|
<ul class="nav navbar-nav pull-right visible-xs">
|
||||||
<li class="dropdown profile-dropdown">
|
<li class="dropdown profile-dropdown">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
<img src="/static/images/samples/scarlet-159.png" alt=""/>
|
<img src="__static__/images/samples/scarlet-159.png" alt=""/>
|
||||||
<span class="hidden-xs">admin</span> <b class="caret"></b>
|
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/user/edit.html">
|
<a href="{:url('/admin/User/edit')}">
|
||||||
<i class="fa fa-user"></i>
|
<i class="fa fa-user"></i>
|
||||||
修改资料
|
修改资料
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/user/editpwd.html">
|
<a href="{:url('/admin/User/editpwd')}">
|
||||||
<i class="fa fa-cog"></i>
|
<i class="fa fa-cog"></i>
|
||||||
修改密码
|
修改密码
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/logout.html">
|
<a href="{:url('/admin/index/logout')}">
|
||||||
<i class="fa fa-power-off"></i>
|
<i class="fa fa-power-off"></i>
|
||||||
退出后台
|
退出后台
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="http://www.tensent.cn" target="_blank">
|
<a href="{$config['web_site_url']|default='/'}" target="_blank">
|
||||||
<i class="fa fa-home"></i>
|
<i class="fa fa-home"></i>
|
||||||
前台首页
|
前台首页
|
||||||
</a>
|
</a>
|
||||||
@@ -74,9 +73,9 @@
|
|||||||
<div class="collapse navbar-collapse" id="header-nav">
|
<div class="collapse navbar-collapse" id="header-nav">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
{volist name="headerMenu" id="item"}
|
{volist name="headerMenu" id="item"}
|
||||||
<li class="{if isset($item['active']) && $item['active']}active{/if}">
|
<li {if isset($item['active']) && $item['active']}class="active"{/if}>
|
||||||
<a href="{:url($item['url'])}">
|
<a href="{$item['url']|url}">
|
||||||
<i class="fa fa-{$item['icon']}"></i>
|
<i class="fa fa-{$item['icon']|default='file'}"></i>
|
||||||
<span>{$item['title']}</span>
|
<span>{$item['title']}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -85,30 +84,30 @@
|
|||||||
<ul class="nav navbar-nav pull-right">
|
<ul class="nav navbar-nav pull-right">
|
||||||
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
<img src="/static/images/samples/scarlet-159.png" alt=""/>
|
<img src="__static__/images/samples/scarlet-159.png" alt=""/>
|
||||||
<span class="hidden-xs">admin</span> <b class="caret"></b>
|
<span class="hidden-xs">{:session('user_auth.username')}</span> <b class="caret"></b>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/user/edit.html">
|
<a href="{:url('admin/User/edit')}">
|
||||||
<i class="fa fa-user"></i>
|
<i class="fa fa-user"></i>
|
||||||
修改资料
|
修改资料
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/user/editpwd.html">
|
<a href="{:url('admin/User/editpwd')}">
|
||||||
<i class="fa fa-cog"></i>
|
<i class="fa fa-cog"></i>
|
||||||
修改密码
|
修改密码
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/logout.html">
|
<a href="{:url('admin/index/logout')}">
|
||||||
<i class="fa fa-power-off"></i>
|
<i class="fa fa-power-off"></i>
|
||||||
退出后台
|
退出后台
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="http://www.tensent.cn" target="_blank">
|
<a href="{$config['web_site_url']|default='/'}" target="_blank">
|
||||||
<i class="fa fa-home"></i>
|
<i class="fa fa-home"></i>
|
||||||
前台首页
|
前台首页
|
||||||
</a>
|
</a>
|
||||||
@@ -125,6 +124,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div id="page-wrapper" class="container nav-small">
|
<div id="page-wrapper" class="container nav-small">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="nav-col">
|
<div id="nav-col">
|
||||||
@@ -132,12 +132,50 @@
|
|||||||
<div id="col-left-inner" class="col-left-nano-content">
|
<div id="col-left-inner" class="col-left-nano-content">
|
||||||
<div id="sidebar-nav">
|
<div id="sidebar-nav">
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
{volist name="asideMenu" id="menu"}
|
{volist name="asideMenu" id="nav"}
|
||||||
<li class="nav-header hidden-sm hidden-xs">{$key}</li>
|
<li class="nav-header hidden-sm hidden-xs">{$key}</li>
|
||||||
{volist name="menu" id="item"}
|
{volist name="nav" id="item"}
|
||||||
<li {if $item['active']}class="active"{/if}><a href="{:url($item['url'])}"><i class="fa fa-{$item['icon']}"></i><span>{$item['title']}</span></a></li>
|
{if isset($item['_child'])}
|
||||||
|
<li {if isset($item['active']) && $item['active']}class="active"{/if}>
|
||||||
|
<a href="#" class="dropdown-toggle">
|
||||||
|
<i class="fa fa-{$item['icon']|default='file'}"></i>
|
||||||
|
<span>{$item['title']}</span>
|
||||||
|
<i class="fa fa-angle-right drop-icon"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="submenu">
|
||||||
|
{volist name="item['_child']" id="vo" key="k"}
|
||||||
|
<li class="{$vo['active']}">
|
||||||
|
<a href="{$vo['url']|url}">
|
||||||
|
<i class="fa fa-{$vo['icon']|default='file'}"></i>
|
||||||
|
<span>{$vo['title']}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{/volist}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
{else/}
|
||||||
|
<li {if isset($item['active']) && $item['active']}class="active"{/if}>
|
||||||
|
<a href="{$item['url']|url}">
|
||||||
|
<i class="fa fa-{$item['icon']|default='file'}"></i>
|
||||||
|
<span>{$item['title']}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
{/volist}
|
{/volist}
|
||||||
{/volist}
|
{/volist}
|
||||||
|
{if isset($extend_menu)}
|
||||||
|
{volist name="extend_menu" id="sub"}
|
||||||
|
{if is_string($key)}<li class="nav-header hidden-sm hidden-xs">{$key}</li>{/if}
|
||||||
|
{volist name="sub" id="item"}
|
||||||
|
<li {if isset($item['active']) && $item['active']}class="active"{/if}>
|
||||||
|
<a href="{$item['url']|url}">
|
||||||
|
<i class="fa fa-{$item['icon']|default='file'}"></i>
|
||||||
|
<span>{$item['title']}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{/volist}
|
||||||
|
{/volist}
|
||||||
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,10 +192,14 @@
|
|||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li>
|
<li>
|
||||||
<a href="/Admin/index/index.html">后台首页</a>
|
<a href="{:url('Admin/Index/index')}">后台首页</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<span>后台首页</span>
|
{if isset($meta_title)}
|
||||||
|
<span>{$meta_title}</span>
|
||||||
|
{else/}
|
||||||
|
<span>{:lang(request()->controller().'_'.request()->action())}</span>
|
||||||
|
{/if}
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@@ -168,19 +210,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
{block name="body"}
|
{block name="body"}{/block}
|
||||||
<div class="main-box clearfix">
|
|
||||||
<header class="main-box-header clearfix">
|
|
||||||
<div class="pull-left">
|
|
||||||
<h2>{$meta|default='新功能'}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="pull-right">
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<div class="main-box-body clearfix">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/block}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -193,7 +223,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{include file="admin/setting"}
|
{include file="admin/setting"}
|
||||||
<script src="__js__/skin-changer.js"></script>
|
<script type="text/javascript" src="__static__/libs/jquery/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript" src="__static__/libs/nanoscroller/jquery.nanoscroller.min.js"></script>
|
||||||
|
<script type="text/javascript" src="__static__/libs/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<script type="text/javascript" src="__static__/libs/hopscotch/hopscotch.js"></script>
|
||||||
|
<script src="__js__/app.js"></script>
|
||||||
<script type="text/javascript" src="__static__/libs/requirejs/require.js" data-main="__js__/main.js?v={$system_version|default='4.0.0'}"></script>
|
<script type="text/javascript" src="__static__/libs/requirejs/require.js" data-main="__js__/main.js?v={$system_version|default='4.0.0'}"></script>
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
@@ -47,14 +47,14 @@
|
|||||||
<textarea class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:80%; height:120px;">{$item['value']}</textarea>
|
<textarea class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:80%; height:120px;">{$item['value']}</textarea>
|
||||||
{/case}
|
{/case}
|
||||||
{case value="select"}
|
{case value="select"}
|
||||||
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
|
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" data-toggle='cxselect' style="width:auto;">
|
||||||
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
||||||
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
{/case}
|
{/case}
|
||||||
{case value="bool"}
|
{case value="bool"}
|
||||||
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" style="width:auto;">
|
<select class="form-control" name="config[{$item['name']}]" id="config[{$item['name']}]" data-toggle='cxselect' style="width:auto;">
|
||||||
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
{volist name=":parse_config_attr($item['extra'])" id="vo"}
|
||||||
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="main-box clearfix">
|
<div class="main-box clearfix">
|
||||||
<header class="main-box-header clearfix">
|
<header class="main-box-header clearfix">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<h2>网站设置</h2>
|
<h2>{$meta_title|default="新功能"}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="{:url('Config/group')}" class="btn btn-danger">
|
<a href="{:url('Config/group')}" class="btn btn-danger">
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
{extend name="admin/base"/}
|
{extend name="admin/base"/}
|
||||||
|
|
||||||
{block name="body"}
|
{block name="body"}
|
||||||
|
<Card style="width:350px">
|
||||||
|
<p slot="title">
|
||||||
|
<Icon type="ios-film-outline"></Icon>
|
||||||
|
Classic film
|
||||||
|
</p>
|
||||||
|
<Input v-model="value" placeholder="Enter something..." style="width: 300px" />
|
||||||
|
</Card>
|
||||||
{/block}
|
{/block}
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
@@ -1,74 +1,51 @@
|
|||||||
<div class="closed" id="config-tool">
|
<div id="config-tool" class="closed hidden-sm">
|
||||||
<a id="config-tool-cog"><i class="fa fa-cog"></i></a>
|
<a id="config-tool-cog">
|
||||||
|
<i class="fa fa-cog"></i>
|
||||||
|
</a>
|
||||||
<div id="config-tool-options">
|
<div id="config-tool-options">
|
||||||
<h4>布局选项</h4>
|
<h4>布局选项</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<div class="checkbox-nice">
|
<div class="checkbox-nice">
|
||||||
<input id="config-fixed-header" type="checkbox"/>
|
<input type="checkbox" id="config-boxed-layout"/>
|
||||||
<label for="config-fixed-header">固定头部</label>
|
<label for="config-boxed-layout">内嵌布局</label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="checkbox-nice">
|
<div class="checkbox-nice">
|
||||||
<input id="config-fixed-sidebar" type="checkbox"/>
|
<input type="checkbox" id="config-sidebar-samll"/>
|
||||||
<label for="config-fixed-sidebar">固定左侧菜单</label>
|
<label for="config-sidebar-samll">小菜单</label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div class="checkbox-nice">
|
|
||||||
<input id="config-fixed-footer" type="checkbox"/>
|
|
||||||
<label for="config-fixed-footer">固定底部</label>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<div class="checkbox-nice">
|
|
||||||
<input id="config-boxed-layout" type="checkbox"/>
|
|
||||||
<label for="config-boxed-layout">盒式布局</label>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<!-- <li>
|
|
||||||
<div class="checkbox-nice">
|
|
||||||
<input id="config-rtl-layout" type="checkbox"/>
|
|
||||||
<label for="config-rtl-layout">左右翻转</label>
|
|
||||||
</div>
|
|
||||||
</li> -->
|
|
||||||
</ul>
|
</ul>
|
||||||
<br/>
|
<br/>
|
||||||
<h4>主题颜色</h4>
|
<h4>皮肤颜色</h4>
|
||||||
<ul class="clearfix" id="skin-colors">
|
<ul id="skin-colors" class="clearfix">
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="" data-toggle="tooltip" style="background-color: #34495e;" title="Default">
|
<a class="skin-changer" data-skin="" data-toggle="tooltip" title="默认" style="background-color: #34495e;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-white" data-toggle="tooltip" style="background-color: #2ecc71;" title="White/Green">
|
<a class="skin-changer" data-skin="theme-white" data-toggle="tooltip" title="白/绿" style="background-color: #2ecc71;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer blue-gradient" data-skin="theme-blue-gradient" data-toggle="tooltip" title="Gradient">
|
<a class="skin-changer blue-gradient" data-skin="theme-blue-gradient" data-toggle="tooltip" title="渐变"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-turquoise" data-toggle="tooltip" style="background-color: #1abc9c;" title="Green Sea">
|
<a class="skin-changer" data-skin="theme-turquoise" data-toggle="tooltip" title="绿色海洋" style="background-color: #1abc9c;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-amethyst" data-toggle="tooltip" style="background-color: #9b59b6;" title="Amethyst">
|
<a class="skin-changer" data-skin="theme-amethyst" data-toggle="tooltip" title="紫水晶" style="background-color: #9b59b6;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-blue" data-toggle="tooltip" style="background-color: #2980b9;" title="Blue">
|
<a class="skin-changer" data-skin="theme-blue" data-toggle="tooltip" title="蓝色" style="background-color: #2980b9;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-red" data-toggle="tooltip" style="background-color: #e74c3c;" title="Red">
|
<a class="skin-changer" data-skin="theme-red" data-toggle="tooltip" title="红色" style="background-color: #e74c3c;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="skin-changer" data-skin="theme-whbl" data-toggle="tooltip" style="background-color: #3498db;" title="White/Blue">
|
<a class="skin-changer" data-skin="theme-whbl" data-toggle="tooltip" title="白/蓝" style="background-color: #3498db;"></a>
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="__js__/skin-changer.js"></script>
|
||||||
@@ -11,7 +11,7 @@ textarea{resize:none; min-height: 80px;}
|
|||||||
}
|
}
|
||||||
}body {
|
}body {
|
||||||
color:#212121;
|
color:#212121;
|
||||||
background:url("../../images/whitey.jpg") repeat scroll 0 0 #fff;
|
background:url("../images/whitey.jpg") repeat scroll 0 0 #fff;
|
||||||
background-size:220px 220px;
|
background-size:220px 220px;
|
||||||
}
|
}
|
||||||
h1,h2,h3,h4,h5,h6 {
|
h1,h2,h3,h4,h5,h6 {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
$(function($) {
|
$(function($) {
|
||||||
|
|
||||||
var storage, fail, uid;
|
var storage, fail, uid;
|
||||||
try {
|
try {
|
||||||
uid = new Date;
|
uid = new Date; (storage = window.localStorage).setItem(uid, uid);
|
||||||
(storage = window.localStorage).setItem(uid, uid);
|
|
||||||
fail = storage.getItem(uid) != uid;
|
fail = storage.getItem(uid) != uid;
|
||||||
storage.removeItem(uid);
|
storage.removeItem(uid);
|
||||||
fail && (storage = false);
|
fail && (storage = false);
|
||||||
@@ -14,73 +14,44 @@ $(function($) {
|
|||||||
$('#skin-colors .skin-changer').removeClass('active');
|
$('#skin-colors .skin-changer').removeClass('active');
|
||||||
$('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
|
$('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
|
||||||
}
|
}
|
||||||
var fixedHeader = localStorage.getItem('config-fixed-header');
|
|
||||||
if (fixedHeader == 'fixed-header') {
|
//固定头部、左侧菜单以及底部版权信息
|
||||||
$('body').addClass(fixedHeader);
|
$('body').addClass('fixed-header');
|
||||||
$('#config-fixed-header').prop('checked', true);
|
$('body').addClass('fixed-footer');
|
||||||
}
|
$('body').addClass('fixed-leftmenu');
|
||||||
var fixedFooter = localStorage.getItem('config-fixed-footer');
|
|
||||||
if (fixedFooter == 'fixed-footer') {
|
|
||||||
$('body').addClass(fixedFooter);
|
|
||||||
$('#config-fixed-footer').prop('checked', true);
|
|
||||||
}
|
|
||||||
var boxedLayout = localStorage.getItem('config-boxed-layout');
|
|
||||||
if (boxedLayout == 'boxed-layout') {
|
|
||||||
$('body').addClass(boxedLayout);
|
|
||||||
$('#config-boxed-layout').prop('checked', true);
|
|
||||||
}
|
|
||||||
var rtlLayout = localStorage.getItem('config-rtl-layout');
|
|
||||||
if (rtlLayout == 'rtl') {
|
|
||||||
$('body').addClass(rtlLayout);
|
|
||||||
$('#config-rtl-layout').prop('checked', true);
|
|
||||||
}
|
|
||||||
var fixedLeftmenu = localStorage.getItem('config-fixed-leftmenu');
|
|
||||||
if (fixedLeftmenu == 'fixed-leftmenu') {
|
|
||||||
$('body').addClass(fixedLeftmenu);
|
|
||||||
$('#config-fixed-sidebar').prop('checked', true);
|
|
||||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
if ($('#page-wrapper').hasClass('nav-small')) {
|
||||||
$('#page-wrapper').removeClass('nav-small');
|
$('#page-wrapper').removeClass('nav-small');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||||
alwaysVisible: true,
|
alwaysVisible: true,
|
||||||
iOSNativeScrolling: false,
|
iOSNativeScrolling: false,
|
||||||
preventPageScrolling: true,
|
preventPageScrolling: true,
|
||||||
contentClass: 'col-left-nano-content'
|
contentClass: 'col-left-nano-content'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var boxedLayout = localStorage.getItem('config-boxed-layout');
|
||||||
|
if (boxedLayout == 'boxed-layout') {
|
||||||
|
$('body').addClass(boxedLayout);
|
||||||
|
$('#config-boxed-layout').prop('checked', true);
|
||||||
}
|
}
|
||||||
|
var sidebarSamll = localStorage.getItem('config-sidebar-samll');
|
||||||
|
if (sidebarSamll == 'sidebar-samll') {
|
||||||
|
$('#config-sidebar-samll').prop('checked', true);
|
||||||
|
$('#page-wrapper').addClass('nav-small');
|
||||||
|
} else {
|
||||||
|
$('#page-wrapper').removeClass('nav-small');
|
||||||
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#config-tool-cog').on('click', function() {
|
$('#config-tool-cog').on('click',
|
||||||
|
function() {
|
||||||
$('#config-tool').toggleClass('closed');
|
$('#config-tool').toggleClass('closed');
|
||||||
});
|
});
|
||||||
$('#config-fixed-header').on('change', function() {
|
$('#config-boxed-layout').on('change',
|
||||||
var fixedHeader = '';
|
function() {
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('body').addClass('fixed-header');
|
|
||||||
fixedHeader = 'fixed-header';
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('fixed-header');
|
|
||||||
if ($('#config-fixed-sidebar').is(':checked')) {
|
|
||||||
$('#config-fixed-sidebar').prop('checked', false);
|
|
||||||
$('#config-fixed-sidebar').trigger('change');
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeStorage(storage, 'config-fixed-header', fixedHeader);
|
|
||||||
});
|
|
||||||
$('#config-fixed-footer').on('change', function() {
|
|
||||||
var fixedFooter = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('body').addClass('fixed-footer');
|
|
||||||
fixedFooter = 'fixed-footer';
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('fixed-footer');
|
|
||||||
}
|
|
||||||
writeStorage(storage, 'config-fixed-footer', fixedFooter);
|
|
||||||
});
|
|
||||||
$('#config-boxed-layout').on('change', function() {
|
|
||||||
var boxedLayout = '';
|
var boxedLayout = '';
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
$('body').addClass('boxed-layout');
|
$('body').addClass('boxed-layout');
|
||||||
@@ -90,59 +61,42 @@ $(function($) {
|
|||||||
}
|
}
|
||||||
writeStorage(storage, 'config-boxed-layout', boxedLayout);
|
writeStorage(storage, 'config-boxed-layout', boxedLayout);
|
||||||
});
|
});
|
||||||
$('#config-rtl-layout').on('change', function() {
|
|
||||||
var rtlLayout = '';
|
$('#config-sidebar-samll').on('change',function(){
|
||||||
|
var sidebarSamll = '';
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
rtlLayout = 'rtl';
|
$('#page-wrapper').addClass('nav-small');
|
||||||
} else {}
|
sidebarSamll = 'sidebar-samll';
|
||||||
writeStorage(storage, 'config-rtl-layout', rtlLayout);
|
writeStorage(storage, 'config-sidebar-samll', sidebarSamll);
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
$('#config-fixed-sidebar').on('change', function() {
|
|
||||||
var fixedSidebar = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
if (!$('#config-fixed-header').is(':checked')) {
|
|
||||||
$('#config-fixed-header').prop('checked', true);
|
|
||||||
$('#config-fixed-header').trigger('change');
|
|
||||||
}
|
|
||||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
|
||||||
$('#page-wrapper').removeClass('nav-small');
|
|
||||||
}
|
|
||||||
$('body').addClass('fixed-leftmenu');
|
|
||||||
fixedSidebar = 'fixed-leftmenu';
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
|
||||||
alwaysVisible: true,
|
|
||||||
iOSNativeScrolling: false,
|
|
||||||
preventPageScrolling: true,
|
|
||||||
contentClass: 'col-left-nano-content'
|
|
||||||
});
|
|
||||||
writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
|
||||||
} else {
|
} else {
|
||||||
$('body').removeClass('fixed-leftmenu');
|
$('#page-wrapper').removeClass('nav-small');
|
||||||
writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
writeStorage(storage, 'config-sidebar-samll', sidebarSamll);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
if (!storage) {
|
if (!storage) {
|
||||||
$('#config-fixed-header').prop('checked', false);
|
|
||||||
$('#config-fixed-footer').prop('checked', false);
|
|
||||||
$('#config-fixed-sidebar').prop('checked', false);
|
|
||||||
$('#config-boxed-layout').prop('checked', false);
|
$('#config-boxed-layout').prop('checked', false);
|
||||||
$('#config-rtl-layout').prop('checked', false);
|
$('#config-sidebar-samll').prop('checked', false);
|
||||||
}
|
}
|
||||||
$('#skin-colors .skin-changer').on('click', function() {
|
$('#skin-colors .skin-changer').on('click',
|
||||||
|
function() {
|
||||||
$('body').removeClassPrefix('theme-');
|
$('body').removeClassPrefix('theme-');
|
||||||
$('body').addClass($(this).data('skin'));
|
$('body').addClass($(this).data('skin'));
|
||||||
$('#skin-colors .skin-changer').removeClass('active');
|
$('#skin-colors .skin-changer').removeClass('active');
|
||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
writeStorage(storage, 'config-skin', $(this).data('skin'));
|
writeStorage(storage, 'config-skin', $(this).data('skin'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//合并自script.js
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('#content-wrapper > .row').css({
|
$('#content-wrapper > .row').css({
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
}, 200);
|
},
|
||||||
$('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle', function(e) {
|
200);
|
||||||
|
$('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle',
|
||||||
|
function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $item = $(this).parent();
|
var $item = $(this).parent();
|
||||||
if (!$item.hasClass('open')) {
|
if (!$item.hasClass('open')) {
|
||||||
@@ -156,7 +110,8 @@ $(function($) {
|
|||||||
$item.children('.submenu').slideUp('fast');
|
$item.children('.submenu').slideUp('fast');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle', function(e) {
|
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle',
|
||||||
|
function(e) {
|
||||||
if ($(document).width() >= 992) {
|
if ($(document).width() >= 992) {
|
||||||
var $item = $(this).parent();
|
var $item = $(this).parent();
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
if ($('body').hasClass('fixed-leftmenu')) {
|
||||||
@@ -173,7 +128,8 @@ $(function($) {
|
|||||||
$item.children('.submenu').slideDown('fast');
|
$item.children('.submenu').slideDown('fast');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li', function(e) {
|
$('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li',
|
||||||
|
function(e) {
|
||||||
if ($(document).width() >= 992) {
|
if ($(document).width() >= 992) {
|
||||||
var $item = $(this);
|
var $item = $(this);
|
||||||
if ($item.hasClass('open')) {
|
if ($item.hasClass('open')) {
|
||||||
@@ -184,12 +140,14 @@ $(function($) {
|
|||||||
$item.removeClass('open');
|
$item.removeClass('open');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)', function(e) {
|
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)',
|
||||||
|
function(e) {
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
if ($('body').hasClass('fixed-leftmenu')) {
|
||||||
$('#nav-col-submenu').html('');
|
$('#nav-col-submenu').html('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('body').on('mouseleave', '#page-wrapper.nav-small #nav-col', function(e) {
|
$('body').on('mouseleave', '#page-wrapper.nav-small #nav-col',
|
||||||
|
function(e) {
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
if ($('body').hasClass('fixed-leftmenu')) {
|
||||||
$('#nav-col-submenu').html('');
|
$('#nav-col-submenu').html('');
|
||||||
}
|
}
|
||||||
@@ -197,12 +155,10 @@ $(function($) {
|
|||||||
$('#make-small-nav').click(function(e) {
|
$('#make-small-nav').click(function(e) {
|
||||||
$('#page-wrapper').toggleClass('nav-small');
|
$('#page-wrapper').toggleClass('nav-small');
|
||||||
});
|
});
|
||||||
setContentBody();
|
|
||||||
$(window).smartresize(function() {
|
$(window).smartresize(function() {
|
||||||
if ($(document).width() <= 991) {
|
if ($(document).width() <= 991) {
|
||||||
$('#page-wrapper').removeClass('nav-small');
|
$('#page-wrapper').removeClass('nav-small');
|
||||||
}
|
}
|
||||||
setContentBody();
|
|
||||||
});
|
});
|
||||||
$('.mobile-search').click(function(e) {
|
$('.mobile-search').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -215,18 +171,30 @@ $(function($) {
|
|||||||
container.removeClass('active');
|
container.removeClass('active');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||||
alwaysVisible: false,
|
alwaysVisible: true,
|
||||||
iOSNativeScrolling: false,
|
iOSNativeScrolling: false,
|
||||||
preventPageScrolling: true,
|
preventPageScrolling: true,
|
||||||
contentClass: 'col-left-nano-content'
|
contentClass: 'col-left-nano-content'
|
||||||
});
|
});
|
||||||
|
|
||||||
$("[data-toggle='tooltip']").each(function(index, el) {
|
$("[data-toggle='tooltip']").each(function(index, el) {
|
||||||
$(el).tooltip({
|
$(el).tooltip({
|
||||||
placement: $(this).data("placement") || 'top'
|
placement: $(this).data("placement") || 'top'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
function writeStorage(storage, key, value) {
|
||||||
|
if (storage) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(key, value);
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$.fn.removeClassPrefix = function(prefix) {
|
$.fn.removeClassPrefix = function(prefix) {
|
||||||
this.each(function(i, el) {
|
this.each(function(i, el) {
|
||||||
var classes = el.className.split(" ").filter(function(c) {
|
var classes = el.className.split(" ").filter(function(c) {
|
||||||
@@ -235,14 +203,12 @@ $.fn.removeClassPrefix = function(prefix) {
|
|||||||
el.className = classes.join(" ");
|
el.className = classes.join(" ");
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
};
|
}; (function($, sr) {
|
||||||
(function($, sr) {
|
|
||||||
var debounce = function(func, threshold, execAsap) {
|
var debounce = function(func, threshold, execAsap) {
|
||||||
var timeout;
|
var timeout;
|
||||||
return function debounced() {
|
return function debounced() {
|
||||||
var obj = this,
|
var obj = this,
|
||||||
args = arguments;
|
args = arguments;
|
||||||
|
|
||||||
function delayed() {
|
function delayed() {
|
||||||
if (!execAsap) func.apply(obj, args);
|
if (!execAsap) func.apply(obj, args);
|
||||||
timeout = null;
|
timeout = null;
|
||||||
@@ -257,28 +223,46 @@ $.fn.removeClassPrefix = function(prefix) {
|
|||||||
};
|
};
|
||||||
})(jQuery, 'smartresize');
|
})(jQuery, 'smartresize');
|
||||||
|
|
||||||
function writeStorage(storage, key, value) {
|
function helpIntro(){
|
||||||
if (storage) {
|
var placementRight = 'right';
|
||||||
try {
|
var placementLeft = 'left';
|
||||||
localStorage.setItem(key, value);
|
|
||||||
} catch (e) {
|
if ($('body').hasClass('rtl')) {
|
||||||
console.log(e);
|
placementRight = 'left';
|
||||||
|
placementLeft = 'right';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define the tour!
|
||||||
|
var tour = {
|
||||||
|
id: "Cube-intro",
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: 'make-small-nav',
|
||||||
|
title: "设置小菜单按钮",
|
||||||
|
content: "点击小菜单可以把左侧菜单变成小菜单,增大右侧操作区域!",
|
||||||
|
placement: "bottom",
|
||||||
|
zindex: 999,
|
||||||
|
xOffset: -8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'config-tool-options',
|
||||||
|
title: "后台配置工具",
|
||||||
|
content: "配置后台主题色彩,定制头部、左侧菜单以及底部信息",
|
||||||
|
placement: placementLeft,
|
||||||
|
zindex: 999,
|
||||||
|
fixedElement: true,
|
||||||
|
xOffset: -55
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: 'sidebar-nav',
|
||||||
|
title: "左侧导航区域",
|
||||||
|
content: "左侧功能导航区域。",
|
||||||
|
placement: placementRight
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
$.fn.removeClassPrefix = function(prefix) {
|
showPrevButton: true
|
||||||
this.each(function(i, el) {
|
|
||||||
var classes = el.className.split(" ").filter(function(c) {
|
|
||||||
return c.lastIndexOf(prefix, 0) !== 0;
|
|
||||||
});
|
|
||||||
el.className = classes.join(" ");
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function setContentBody() {
|
// Start the tour!
|
||||||
header_height = $('header#header-navbar').height();
|
hopscotch.startTour(tour);
|
||||||
if ($(window).height() - header_height - 50 > $('#content-wrapper').height()) {
|
|
||||||
$('#content-wrapper').height($(window).height() - header_height - 50);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,290 +1,20 @@
|
|||||||
define(['jquery', 'hopscotch'], function($, hopscotch){
|
define(['jquery'], function($){
|
||||||
var Backend = {
|
var Backend = {
|
||||||
|
|
||||||
writeStorage: function(storage, key, value) {
|
|
||||||
if (storage) {
|
|
||||||
try {
|
|
||||||
localStorage.setItem(key, value);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
helpIntro: function(){
|
|
||||||
var placementRight = 'right';
|
|
||||||
var placementLeft = 'left';
|
|
||||||
|
|
||||||
if ($('body').hasClass('rtl')) {
|
|
||||||
placementRight = 'left';
|
|
||||||
placementLeft = 'right';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the tour!
|
|
||||||
var tour = {
|
|
||||||
id: "Cube-intro",
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
target: 'make-small-nav',
|
|
||||||
title: "设置小菜单按钮",
|
|
||||||
content: "点击小菜单可以把左侧菜单变成小菜单,增大右侧操作区域!",
|
|
||||||
placement: "bottom",
|
|
||||||
zindex: 999,
|
|
||||||
xOffset: -8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'config-tool-options',
|
|
||||||
title: "后台配置工具",
|
|
||||||
content: "配置后台主题色彩,定制头部、左侧菜单以及底部信息",
|
|
||||||
placement: placementLeft,
|
|
||||||
zindex: 999,
|
|
||||||
fixedElement: true,
|
|
||||||
xOffset: -55
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: 'sidebar-nav',
|
|
||||||
title: "左侧导航区域",
|
|
||||||
content: "左侧功能导航区域。",
|
|
||||||
placement: placementRight
|
|
||||||
}
|
|
||||||
],
|
|
||||||
showPrevButton: true
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(hopscotch);
|
|
||||||
// Start the tour!
|
|
||||||
hopscotch.startTour(tour);
|
|
||||||
},
|
|
||||||
|
|
||||||
init: function(){
|
init: function(){
|
||||||
$('.hopscotch').on('click', function(){
|
|
||||||
Backend.helpIntro()
|
},
|
||||||
|
setBodySize: function(){
|
||||||
|
var height = $(window).height();
|
||||||
|
if ($('#content-wrapper').height() < height) {
|
||||||
|
$('#content-wrapper').height($(window).height()-120);
|
||||||
|
}
|
||||||
|
$(window).resize(function(){
|
||||||
|
Backend.setBodySize();
|
||||||
})
|
})
|
||||||
|
|
||||||
var storage, fail, uid;
|
|
||||||
try {
|
|
||||||
uid = new Date;
|
|
||||||
(storage = window.localStorage).setItem(uid, uid);
|
|
||||||
fail = storage.getItem(uid) != uid;
|
|
||||||
storage.removeItem(uid);
|
|
||||||
fail && (storage = false);
|
|
||||||
} catch (e) {}
|
|
||||||
if (storage) {
|
|
||||||
try {
|
|
||||||
var usedSkin = localStorage.getItem('config-skin');
|
|
||||||
if (usedSkin != '') {
|
|
||||||
$('#skin-colors .skin-changer').removeClass('active');
|
|
||||||
$('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
|
|
||||||
}
|
|
||||||
var fixedHeader = localStorage.getItem('config-fixed-header');
|
|
||||||
if (fixedHeader == 'fixed-header') {
|
|
||||||
$('body').addClass(fixedHeader);
|
|
||||||
$('#config-fixed-header').prop('checked', true);
|
|
||||||
}
|
|
||||||
var fixedFooter = localStorage.getItem('config-fixed-footer');
|
|
||||||
if (fixedFooter == 'fixed-footer') {
|
|
||||||
$('body').addClass(fixedFooter);
|
|
||||||
$('#config-fixed-footer').prop('checked', true);
|
|
||||||
}
|
|
||||||
var boxedLayout = localStorage.getItem('config-boxed-layout');
|
|
||||||
if (boxedLayout == 'boxed-layout') {
|
|
||||||
$('body').addClass(boxedLayout);
|
|
||||||
$('#config-boxed-layout').prop('checked', true);
|
|
||||||
}
|
|
||||||
var rtlLayout = localStorage.getItem('config-rtl-layout');
|
|
||||||
if (rtlLayout == 'rtl') {
|
|
||||||
$('body').addClass(rtlLayout);
|
|
||||||
$('#config-rtl-layout').prop('checked', true);
|
|
||||||
}
|
|
||||||
var fixedLeftmenu = localStorage.getItem('config-fixed-leftmenu');
|
|
||||||
if (fixedLeftmenu == 'fixed-leftmenu') {
|
|
||||||
$('body').addClass(fixedLeftmenu);
|
|
||||||
$('#config-fixed-sidebar').prop('checked', true);
|
|
||||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
|
||||||
$('#page-wrapper').removeClass('nav-small');
|
|
||||||
}
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
|
||||||
alwaysVisible: true,
|
|
||||||
iOSNativeScrolling: false,
|
|
||||||
preventPageScrolling: true,
|
|
||||||
contentClass: 'col-left-nano-content'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#config-tool-cog').on('click', function() {
|
|
||||||
$('#config-tool').toggleClass('closed');
|
|
||||||
});
|
|
||||||
$('#config-fixed-header').on('change', function() {
|
|
||||||
var fixedHeader = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('body').addClass('fixed-header');
|
|
||||||
fixedHeader = 'fixed-header';
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('fixed-header');
|
|
||||||
if ($('#config-fixed-sidebar').is(':checked')) {
|
|
||||||
$('#config-fixed-sidebar').prop('checked', false);
|
|
||||||
$('#config-fixed-sidebar').trigger('change');
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Backend.writeStorage(storage, 'config-fixed-header', fixedHeader);
|
|
||||||
});
|
|
||||||
$('#config-fixed-footer').on('change', function() {
|
|
||||||
var fixedFooter = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('body').addClass('fixed-footer');
|
|
||||||
fixedFooter = 'fixed-footer';
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('fixed-footer');
|
|
||||||
}
|
|
||||||
Backend.writeStorage(storage, 'config-fixed-footer', fixedFooter);
|
|
||||||
});
|
|
||||||
$('#config-boxed-layout').on('change', function() {
|
|
||||||
var boxedLayout = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('body').addClass('boxed-layout');
|
|
||||||
boxedLayout = 'boxed-layout';
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('boxed-layout');
|
|
||||||
}
|
|
||||||
Backend.writeStorage(storage, 'config-boxed-layout', boxedLayout);
|
|
||||||
});
|
|
||||||
$('#config-rtl-layout').on('change', function() {
|
|
||||||
var rtlLayout = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
rtlLayout = 'rtl';
|
|
||||||
} else {}
|
|
||||||
Backend.writeStorage(storage, 'config-rtl-layout', rtlLayout);
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
$('#config-fixed-sidebar').on('change', function() {
|
|
||||||
var fixedSidebar = '';
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
if (!$('#config-fixed-header').is(':checked')) {
|
|
||||||
$('#config-fixed-header').prop('checked', true);
|
|
||||||
$('#config-fixed-header').trigger('change');
|
|
||||||
}
|
|
||||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
|
||||||
$('#page-wrapper').removeClass('nav-small');
|
|
||||||
}
|
|
||||||
$('body').addClass('fixed-leftmenu');
|
|
||||||
fixedSidebar = 'fixed-leftmenu';
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
|
||||||
alwaysVisible: true,
|
|
||||||
iOSNativeScrolling: false,
|
|
||||||
preventPageScrolling: true,
|
|
||||||
contentClass: 'col-left-nano-content'
|
|
||||||
});
|
|
||||||
Backend.writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
|
||||||
} else {
|
|
||||||
$('body').removeClass('fixed-leftmenu');
|
|
||||||
Backend.writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!storage) {
|
|
||||||
$('#config-fixed-header').prop('checked', false);
|
|
||||||
$('#config-fixed-footer').prop('checked', false);
|
|
||||||
$('#config-fixed-sidebar').prop('checked', false);
|
|
||||||
$('#config-boxed-layout').prop('checked', false);
|
|
||||||
$('#config-rtl-layout').prop('checked', false);
|
|
||||||
}
|
|
||||||
$('#skin-colors .skin-changer').on('click', function() {
|
|
||||||
$('body').removeClassPrefix('theme-');
|
|
||||||
$('body').addClass($(this).data('skin'));
|
|
||||||
$('#skin-colors .skin-changer').removeClass('active');
|
|
||||||
$(this).addClass('active');
|
|
||||||
Backend.writeStorage(storage, 'config-skin', $(this).data('skin'));
|
|
||||||
});
|
|
||||||
setTimeout(function() {
|
|
||||||
$('#content-wrapper > .row').css({
|
|
||||||
opacity: 1
|
|
||||||
});
|
|
||||||
}, 200);
|
|
||||||
$('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var $item = $(this).parent();
|
|
||||||
if (!$item.hasClass('open')) {
|
|
||||||
$item.parent().find('.open .submenu').slideUp('fast');
|
|
||||||
$item.parent().find('.open').toggleClass('open');
|
|
||||||
}
|
|
||||||
$item.toggleClass('open');
|
|
||||||
if ($item.hasClass('open')) {
|
|
||||||
$item.children('.submenu').slideDown('fast');
|
|
||||||
} else {
|
|
||||||
$item.children('.submenu').slideUp('fast');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle', function(e) {
|
|
||||||
if ($(document).width() >= 992) {
|
|
||||||
var $item = $(this).parent();
|
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
|
||||||
var topPosition = $item.position().top;
|
|
||||||
if ((topPosition + 4 * $(this).outerHeight()) >= $(window).height()) {
|
|
||||||
topPosition -= 6 * $(this).outerHeight();
|
|
||||||
}
|
|
||||||
$('#nav-col-submenu').html($item.children('.submenu').clone());
|
|
||||||
$('#nav-col-submenu > .submenu').css({
|
|
||||||
'top': topPosition
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$item.addClass('open');
|
|
||||||
$item.children('.submenu').slideDown('fast');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li', function(e) {
|
|
||||||
if ($(document).width() >= 992) {
|
|
||||||
var $item = $(this);
|
|
||||||
if ($item.hasClass('open')) {
|
|
||||||
$item.find('.open .submenu').slideUp('fast');
|
|
||||||
$item.find('.open').removeClass('open');
|
|
||||||
$item.children('.submenu').slideUp('fast');
|
|
||||||
}
|
|
||||||
$item.removeClass('open');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)', function(e) {
|
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
|
||||||
$('#nav-col-submenu').html('');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('body').on('mouseleave', '#page-wrapper.nav-small #nav-col', function(e) {
|
|
||||||
if ($('body').hasClass('fixed-leftmenu')) {
|
|
||||||
$('#nav-col-submenu').html('');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#make-small-nav').click(function(e) {
|
|
||||||
$('#page-wrapper').toggleClass('nav-small');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.mobile-search').click(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
$('.mobile-search').addClass('active');
|
|
||||||
$('.mobile-search form input.form-control').focus();
|
|
||||||
});
|
|
||||||
$(document).mouseup(function(e) {
|
|
||||||
var container = $('.mobile-search');
|
|
||||||
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
|
||||||
container.removeClass('active');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
|
||||||
alwaysVisible: false,
|
|
||||||
iOSNativeScrolling: false,
|
|
||||||
preventPageScrolling: true,
|
|
||||||
contentClass: 'col-left-nano-content'
|
|
||||||
});
|
|
||||||
$("[data-toggle='tooltip']").each(function(index, el) {
|
|
||||||
$(el).tooltip({
|
|
||||||
placement: $(this).data("placement") || 'top'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Backend.setBodySize();
|
||||||
Backend.init(); //默认初始化执行的代码
|
Backend.init(); //默认初始化执行的代码
|
||||||
return Backend;
|
return Backend;
|
||||||
})
|
})
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
require.config({
|
require.config({
|
||||||
urlArgs: "v=" + '4.0.0',
|
urlArgs: "v=" + Date(),
|
||||||
packages: [
|
packages: [
|
||||||
{
|
{
|
||||||
name: 'moment',
|
name: 'moment',
|
||||||
@@ -19,7 +19,6 @@ require.config({
|
|||||||
'echarts': 'echarts.min',
|
'echarts': 'echarts.min',
|
||||||
'echarts-theme': 'echarts-theme',
|
'echarts-theme': 'echarts-theme',
|
||||||
|
|
||||||
"vue":'/static/libs/vue/dist/vue.min',
|
|
||||||
"jquery":'/static/libs/jquery/jquery.min',
|
"jquery":'/static/libs/jquery/jquery.min',
|
||||||
"nanoscroller":"/static/libs/nanoscroller/jquery.nanoscroller.min",
|
"nanoscroller":"/static/libs/nanoscroller/jquery.nanoscroller.min",
|
||||||
"slimscroll":"/static/js/jquery.slimscroll.min",
|
"slimscroll":"/static/js/jquery.slimscroll.min",
|
||||||
@@ -67,7 +66,7 @@ require.config({
|
|||||||
'bootstrap-table': {
|
'bootstrap-table': {
|
||||||
deps: [
|
deps: [
|
||||||
'bootstrap',
|
'bootstrap',
|
||||||
// 'css!/static/libs/bootstrap-table/dist/bootstrap-table.min.css'
|
'css!/static/libs/bootstrap-table/dist/bootstrap-table.min.css'
|
||||||
],
|
],
|
||||||
exports: '$.fn.bootstrapTable'
|
exports: '$.fn.bootstrapTable'
|
||||||
},
|
},
|
||||||
@@ -101,21 +100,21 @@ require.config({
|
|||||||
},
|
},
|
||||||
'bootstrap-datetimepicker': [
|
'bootstrap-datetimepicker': [
|
||||||
'moment/locale/zh-cn.js',
|
'moment/locale/zh-cn.js',
|
||||||
// 'css!/static/libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
|
'css!/static/libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
|
||||||
],
|
],
|
||||||
// 'bootstrap-select': ['css!/static/libs/bootstrap-select/dist/css/bootstrap-select.min.css',],
|
'bootstrap-select': ['css!/static/libs/bootstrap-select/dist/css/bootstrap-select.min.css',],
|
||||||
'bootstrap-select-lang': ['bootstrap-select'],
|
'bootstrap-select-lang': ['bootstrap-select'],
|
||||||
// 'toastr': ['css!/static/libs/toastr/toastr.min.css'],
|
'toastr': ['css!/static/libs/toastr/toastr.min.css'],
|
||||||
'jstree': ['css!/static/libs/jstree/dist/themes/default/style.css',],
|
'jstree': ['css!/static/libs/jstree/dist/themes/default/style.css',],
|
||||||
'plupload': {
|
'plupload': {
|
||||||
deps: ['/static/libs/plupload/js/moxie.min.js'],
|
deps: ['/static/libs/plupload/js/moxie.min.js'],
|
||||||
exports: "plupload"
|
exports: "plupload"
|
||||||
},
|
},
|
||||||
// 'layer': ['css!/static/libs/fastadmin-layer/dist/theme/default/layer.css'],
|
'layer': ['css!/static/libs/fastadmin-layer/dist/theme/default/layer.css'],
|
||||||
// 'validator-core': ['css!/static/libs/nice-validator/dist/jquery.validator.css'],
|
'validator-core': ['css!/static/libs/nice-validator/dist/jquery.validator.css'],
|
||||||
'validator-lang': ['validator-core'],
|
'validator-lang': ['validator-core'],
|
||||||
// 'selectpage': ['css!/static/libs/fastadmin-selectpage/selectpage.css'],
|
'selectpage': ['css!/static/libs/fastadmin-selectpage/selectpage.css'],
|
||||||
'citypicker': ['citypicker-data', 'css!/static/libs/fastadmin-citypicker/dist/css/city-picker.css']
|
'citypicker': ['citypicker-data', 'css!/static/libs/fastadmin-citypicker/dist/css/city-picker.css'],
|
||||||
},
|
},
|
||||||
baseUrl:"/static/js/",
|
baseUrl:"/static/js/",
|
||||||
map: {
|
map: {
|
||||||
@@ -128,7 +127,7 @@ require.config({
|
|||||||
charset: 'utf-8' // 文件编码
|
charset: 'utf-8' // 文件编码
|
||||||
});
|
});
|
||||||
|
|
||||||
require(['jquery', 'nanoscroller', 'bootstrap', 'sent'], function($, undefined, undefined, Sent){
|
require(['jquery', 'sent'], function($, Sent){
|
||||||
$(function($) {
|
$(function($) {
|
||||||
require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
|
require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
|
||||||
// 避免目录冲突
|
// 避免目录冲突
|
||||||
@@ -150,23 +149,5 @@ require(['jquery', 'nanoscroller', 'bootstrap', 'sent'], function($, undefined,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
$.fn.removeClassPrefix = function(prefix) {
|
|
||||||
this.each(function(i, el) {
|
|
||||||
var classes = el.className.split(" ").filter(function(c) {
|
|
||||||
return c.lastIndexOf(prefix, 0) !== 0;
|
|
||||||
});
|
|
||||||
el.className = classes.join(" ");
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function setContentBody() {
|
|
||||||
header_height = $('header#header-navbar').height();
|
|
||||||
if ($(window).height() - header_height - 50 > $('#content-wrapper').height()) {
|
|
||||||
$('#content-wrapper').height($(window).height() - header_height - 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -1,7 +1,15 @@
|
|||||||
define(['vue'],function(Vue){
|
define(['vue', 'iview'],function(Vue, iView){
|
||||||
var controller = {
|
var controller = {
|
||||||
clear: function(){
|
clear: function(){
|
||||||
var vm = new Vue();
|
var vm = new Vue({
|
||||||
|
el:'.vue-main',
|
||||||
|
data:{
|
||||||
|
value:''
|
||||||
|
},
|
||||||
|
created(){
|
||||||
|
this.$Message.success('这是一条成功的提示');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
179
public/static/js/require-form.js
Normal file
179
public/static/js/require-form.js
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
define(['jquery', 'sent', 'validator'], function($, Sent, Validator){
|
||||||
|
var Form = {
|
||||||
|
events: {
|
||||||
|
validator: function (form, success, error, submit) {
|
||||||
|
if (!form.is("form")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//绑定表单事件
|
||||||
|
form.validator($.extend({
|
||||||
|
valid: function (ret) {
|
||||||
|
var that = this, submitBtn = $("button.submit-btn", form);
|
||||||
|
that.holdSubmit(true);
|
||||||
|
submitBtn.addClass("disabled");
|
||||||
|
//验证通过提交表单
|
||||||
|
var submitResult = Form.api.submit($(ret), function (data, ret) {
|
||||||
|
that.holdSubmit(false);
|
||||||
|
submitBtn.removeClass("disabled");
|
||||||
|
if (false === $(this).triggerHandler("success.form", [data, ret])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (typeof success === 'function') {
|
||||||
|
if (false === success.call($(this), data, ret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//提示及关闭当前窗口
|
||||||
|
var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : 'Operation completed';
|
||||||
|
parent.Toastr.success(msg);
|
||||||
|
parent.$(".btn-refresh").trigger("click");
|
||||||
|
var index = parent.Layer.getFrameIndex(window.name);
|
||||||
|
parent.Layer.close(index);
|
||||||
|
return false;
|
||||||
|
}, function(data, ret){
|
||||||
|
that.holdSubmit(false);
|
||||||
|
if (false === $(this).triggerHandler("error.form", [data, ret])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
submitBtn.removeClass("disabled");
|
||||||
|
if (typeof error === 'function') {
|
||||||
|
if (false === error.call($(this), data, ret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, submit)
|
||||||
|
//如果提交失败则释放锁定
|
||||||
|
if (!submitResult) {
|
||||||
|
that.holdSubmit(false);
|
||||||
|
submitBtn.removeClass("disabled");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, form.data("validator-options") || {}))
|
||||||
|
|
||||||
|
//移除提交按钮的disabled类
|
||||||
|
$(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
|
||||||
|
},
|
||||||
|
cxselect: function (form) {
|
||||||
|
//绑定cxselect元素事件
|
||||||
|
if ($("[data-toggle='cxselect']", form).size() > 0) {
|
||||||
|
require(['cxselect'], function () {
|
||||||
|
$.cxSelect.defaults.jsonName = 'name';
|
||||||
|
$.cxSelect.defaults.jsonValue = 'value';
|
||||||
|
$.cxSelect.defaults.jsonSpace = 'data';
|
||||||
|
$("[data-toggle='cxselect']", form).cxSelect();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
switcher: function (form) {
|
||||||
|
form.on("click", "[data-toggle='switcher']", function () {
|
||||||
|
if ($(this).hasClass("disabled")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var input = $(this).prev("input");
|
||||||
|
input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
|
||||||
|
if (input.size() > 0) {
|
||||||
|
var yes = $(this).data("yes");
|
||||||
|
var no = $(this).data("no");
|
||||||
|
if (input.val() == yes) {
|
||||||
|
input.val(no);
|
||||||
|
$("i", this).addClass("fa-flip-horizontal text-gray");
|
||||||
|
} else {
|
||||||
|
input.val(yes);
|
||||||
|
$("i", this).removeClass("fa-flip-horizontal text-gray");
|
||||||
|
}
|
||||||
|
input.trigger('change');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
bindevent: function (form) {
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
api:{
|
||||||
|
submit: function (form, success, error, submit) {
|
||||||
|
if (form.size() === 0) {
|
||||||
|
Toastr.error("表单未初始化完成,无法提交");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (typeof submit === 'function') {
|
||||||
|
if (false === submit.call(form, success, error)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
|
||||||
|
type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
|
||||||
|
url = form.attr("action");
|
||||||
|
url = url ? url : location.href;
|
||||||
|
//修复当存在多选项元素时提交的BUG
|
||||||
|
var params = {};
|
||||||
|
var multipleList = $("[name$='[]']", form);
|
||||||
|
if (multipleList.size() > 0) {
|
||||||
|
var postFields = form.serializeArray().map(function (obj) {
|
||||||
|
return $(obj).prop("name");
|
||||||
|
});
|
||||||
|
$.each(multipleList, function (i, j) {
|
||||||
|
if (postFields.indexOf($(this).prop("name")) < 0) {
|
||||||
|
params[$(this).prop("name")] = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//调用Ajax请求方法
|
||||||
|
Sent.api.ajax({
|
||||||
|
type: type,
|
||||||
|
url: url,
|
||||||
|
data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
|
||||||
|
dataType: 'json',
|
||||||
|
complete: function (xhr) {
|
||||||
|
var token = xhr.getResponseHeader('__token__');
|
||||||
|
if (token) {
|
||||||
|
$("input[name='__token__']", form).val(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data, ret) {
|
||||||
|
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
||||||
|
if (data && typeof data === 'object') {
|
||||||
|
//刷新客户端token
|
||||||
|
if (typeof data.token !== 'undefined') {
|
||||||
|
$("input[name='__token__']", form).val(data.token);
|
||||||
|
}
|
||||||
|
//调用客户端事件
|
||||||
|
if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
|
||||||
|
data.callback.call(form, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof success === 'function') {
|
||||||
|
if (false === success.call(form, data, ret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function (data, ret) {
|
||||||
|
if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
|
||||||
|
$("input[name='__token__']", form).val(data.token);
|
||||||
|
}
|
||||||
|
if (typeof error === 'function') {
|
||||||
|
if (false === error.call(form, data, ret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
bindevent: function (form, success, error, submit) {
|
||||||
|
form = typeof form === 'object' ? form : $(form);
|
||||||
|
|
||||||
|
var events = Form.events;
|
||||||
|
|
||||||
|
events.bindevent(form);
|
||||||
|
|
||||||
|
events.validator(form, success, error, submit);
|
||||||
|
|
||||||
|
events.cxselect(form);
|
||||||
|
events.switcher(form);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Form;
|
||||||
|
})
|
||||||
@@ -1,10 +1,268 @@
|
|||||||
define(['jquery'], function($){
|
define(['jquery', 'toastr','layer'], function($, Toastr, Layer){
|
||||||
var Sent = {
|
var Sent = {
|
||||||
|
config: {
|
||||||
|
//toastr默认配置
|
||||||
|
toastr: {
|
||||||
|
"closeButton": true,
|
||||||
|
"debug": false,
|
||||||
|
"newestOnTop": false,
|
||||||
|
"progressBar": false,
|
||||||
|
"positionClass": "toast-top-center",
|
||||||
|
"preventDuplicates": false,
|
||||||
|
"onclick": null,
|
||||||
|
"showDuration": "300",
|
||||||
|
"hideDuration": "1000",
|
||||||
|
"timeOut": "5000",
|
||||||
|
"extendedTimeOut": "1000",
|
||||||
|
"showEasing": "swing",
|
||||||
|
"hideEasing": "linear",
|
||||||
|
"showMethod": "fadeIn",
|
||||||
|
"hideMethod": "fadeOut"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
|
//公共代码
|
||||||
|
//配置Toastr的参数
|
||||||
|
Toastr.options = Sent.config.toastr;
|
||||||
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
//请求成功的回调
|
||||||
|
onAjaxSuccess: function (ret, onAjaxSuccess) {
|
||||||
|
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||||
|
var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : 'Operation completed';
|
||||||
|
|
||||||
|
if (typeof onAjaxSuccess === 'function') {
|
||||||
|
var result = onAjaxSuccess.call(this, data, ret);
|
||||||
|
if (result === false)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toastr.success(msg);
|
||||||
|
},
|
||||||
|
//请求错误的回调
|
||||||
|
onAjaxError: function (ret, onAjaxError) {
|
||||||
|
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||||
|
if (typeof onAjaxError === 'function') {
|
||||||
|
var result = onAjaxError.call(this, data, ret);
|
||||||
|
if (result === false) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Toastr.error(ret.msg);
|
||||||
|
},
|
||||||
|
//服务器响应数据后
|
||||||
|
onAjaxResponse: function (response) {
|
||||||
|
try {
|
||||||
|
var ret = typeof response === 'object' ? response : JSON.parse(response);
|
||||||
|
if (!ret.hasOwnProperty('code')) {
|
||||||
|
$.extend(ret, {code: -2, msg: response, data: null});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
var ret = {code: -1, msg: e.message, data: null};
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
api: {
|
||||||
|
//发送Ajax请求
|
||||||
|
ajax: function (options, success, error) {
|
||||||
|
options = typeof options === 'string' ? {url: options} : options;
|
||||||
|
var index;
|
||||||
|
if (typeof options.loading === 'undefined' || options.loading) {
|
||||||
|
index = Layer.load(options.loading || 0);
|
||||||
|
}
|
||||||
|
options = $.extend({
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (ret) {
|
||||||
|
index && Layer.close(index);
|
||||||
|
ret = Sent.events.onAjaxResponse(ret);
|
||||||
|
if (ret.code === 0) {
|
||||||
|
Sent.events.onAjaxSuccess(ret, success);
|
||||||
|
} else {
|
||||||
|
Sent.events.onAjaxError(ret, error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
index && Layer.close(index);
|
||||||
|
var ret = {code: xhr.status, msg: xhr.statusText, data: null};
|
||||||
|
Sent.events.onAjaxError(ret, error);
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
$.ajax(options);
|
||||||
|
},
|
||||||
|
//查询Url参数
|
||||||
|
query: function (name, url) {
|
||||||
|
if (!url) {
|
||||||
|
url = window.location.href;
|
||||||
|
}
|
||||||
|
name = name.replace(/[\[\]]/g, "\\$&");
|
||||||
|
var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
|
||||||
|
results = regex.exec(url);
|
||||||
|
if (!results)
|
||||||
|
return null;
|
||||||
|
if (!results[2])
|
||||||
|
return '';
|
||||||
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||||
|
},
|
||||||
|
//打开一个弹出窗口
|
||||||
|
open: function (url, title, options) {
|
||||||
|
title = options && options.title ? options.title : (title ? title : "");
|
||||||
|
//url = Sent.api.fixurl(url);
|
||||||
|
url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
|
||||||
|
var area = Sent.config.openArea != undefined ? Sent.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
|
||||||
|
options = $.extend({
|
||||||
|
type: 2,
|
||||||
|
title: title,
|
||||||
|
shadeClose: true,
|
||||||
|
shade: false,
|
||||||
|
maxmin: true,
|
||||||
|
moveOut: true,
|
||||||
|
area: area,
|
||||||
|
content: url,
|
||||||
|
zIndex: Layer.zIndex,
|
||||||
|
success: function (layero, index) {
|
||||||
|
var that = this;
|
||||||
|
//存储callback事件
|
||||||
|
$(layero).data("callback", that.callback);
|
||||||
|
//$(layero).removeClass("layui-layer-border");
|
||||||
|
Layer.setTop(layero);
|
||||||
|
try {
|
||||||
|
var frame = Layer.getChildFrame('html', index);
|
||||||
|
var layerfooter = frame.find(".layer-footer");
|
||||||
|
Sent.api.layerfooter(layero, index, that);
|
||||||
|
|
||||||
|
//绑定事件
|
||||||
|
if (layerfooter.size() > 0) {
|
||||||
|
// 监听窗口内的元素及属性变化
|
||||||
|
// Firefox和Chrome早期版本中带有前缀
|
||||||
|
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||||
|
if (MutationObserver) {
|
||||||
|
// 选择目标节点
|
||||||
|
var target = layerfooter[0];
|
||||||
|
// 创建观察者对象
|
||||||
|
var observer = new MutationObserver(function (mutations) {
|
||||||
|
Sent.api.layerfooter(layero, index, that);
|
||||||
|
mutations.forEach(function (mutation) {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// 配置观察选项:
|
||||||
|
var config = {attributes: true, childList: true, characterData: true, subtree: true}
|
||||||
|
// 传入目标节点和观察选项
|
||||||
|
observer.observe(target, config);
|
||||||
|
// 随后,你还可以停止观察
|
||||||
|
// observer.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($(layero).height() > $(window).height()) {
|
||||||
|
//当弹出窗口大于浏览器可视高度时,重定位
|
||||||
|
Layer.style(index, {
|
||||||
|
top: 0,
|
||||||
|
height: $(window).height()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, options ? options : {});
|
||||||
|
if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0)) {
|
||||||
|
options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
|
||||||
|
options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
|
||||||
|
}
|
||||||
|
return Layer.open(options);
|
||||||
|
},
|
||||||
|
//关闭窗口并回传数据
|
||||||
|
close: function (data) {
|
||||||
|
var index = parent.Layer.getFrameIndex(window.name);
|
||||||
|
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||||
|
//再执行关闭
|
||||||
|
parent.Layer.close(index);
|
||||||
|
//再调用回传函数
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback.call(undefined, data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layerfooter: function (layero, index, that) {
|
||||||
|
var frame = Layer.getChildFrame('html', index);
|
||||||
|
var layerfooter = frame.find(".layer-footer");
|
||||||
|
if (layerfooter.size() > 0) {
|
||||||
|
$(".layui-layer-footer", layero).remove();
|
||||||
|
var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
|
||||||
|
footer.html(layerfooter.html());
|
||||||
|
if ($(".row", footer).size() === 0) {
|
||||||
|
$(">", footer).wrapAll("<div class='row'></div>");
|
||||||
|
}
|
||||||
|
footer.insertAfter(layero.find('.layui-layer-content'));
|
||||||
|
//绑定事件
|
||||||
|
footer.on("click", ".btn", function () {
|
||||||
|
if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var index = footer.find('.btn').index(this);
|
||||||
|
$(".btn:eq(" + index + ")", layerfooter).trigger("click");
|
||||||
|
});
|
||||||
|
|
||||||
|
var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
|
||||||
|
var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
|
||||||
|
//重设iframe高度
|
||||||
|
$("iframe", layero).height(layero.height() - titHeight - btnHeight);
|
||||||
|
}
|
||||||
|
//修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
|
||||||
|
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
||||||
|
var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
|
||||||
|
var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
|
||||||
|
$("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
|
||||||
|
$("iframe", layero).css("height", "100%");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: function (options, callback) {
|
||||||
|
var type = typeof options === 'function';
|
||||||
|
if (type) {
|
||||||
|
callback = options;
|
||||||
|
}
|
||||||
|
return Layer.msg('Operation completed', $.extend({
|
||||||
|
offset: 0, icon: 1
|
||||||
|
}, type ? {} : options), callback);
|
||||||
|
},
|
||||||
|
error: function (options, callback) {
|
||||||
|
var type = typeof options === 'function';
|
||||||
|
if (type) {
|
||||||
|
callback = options;
|
||||||
|
}
|
||||||
|
return Layer.msg('Operation failed', $.extend({
|
||||||
|
offset: 0, icon: 2
|
||||||
|
}, type ? {} : options), callback);
|
||||||
|
},
|
||||||
|
msg: function (message, url) {
|
||||||
|
var callback = typeof url === 'function' ? url : function () {
|
||||||
|
if (typeof url !== 'undefined' && url) {
|
||||||
|
location.href = url;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Layer.msg(message, {
|
||||||
|
time: 2000
|
||||||
|
}, callback);
|
||||||
|
},
|
||||||
|
toastr: Toastr,
|
||||||
|
layer: Layer
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if($('form').length > 0){
|
||||||
|
require(['form'], function(Form){
|
||||||
|
Form.api.bindevent($("form"));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//将Layer暴露到全局中去
|
||||||
|
window.Layer = Layer;
|
||||||
|
//将Toastr暴露到全局中去
|
||||||
|
window.Toastr = Toastr;
|
||||||
|
//将Fast渲染至全局
|
||||||
|
window.Sent = Sent;
|
||||||
|
|
||||||
Sent.init(); //默认初始化执行的代码
|
Sent.init(); //默认初始化执行的代码
|
||||||
return Sent;
|
return Sent;
|
||||||
|
|||||||
1
public/static/libs/hopscotch/hopscotch.css
Normal file
1
public/static/libs/hopscotch/hopscotch.css
Normal file
File diff suppressed because one or more lines are too long
179
public/static/libs/hopscotch/hopscotch.js
Normal file
179
public/static/libs/hopscotch/hopscotch.js
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
(function(context,namespace){var Hopscotch,HopscotchBubble,HopscotchCalloutManager,HopscotchI18N,customI18N,customRenderer,customEscape,templateToUse='bubble_default',Sizzle=window.Sizzle||null,utils,callbacks,helpers,winLoadHandler,defaultOpts,winHopscotch=context[namespace],undefinedStr='undefined',waitingToStart=false,hasJquery=(typeof window.jQuery!==undefinedStr),hasSessionStorage=false,isStorageWritable=false,document=window.document;try{if(typeof window.sessionStorage!==undefinedStr){hasSessionStorage=true;sessionStorage.setItem('hopscotch.test.storage','ok');sessionStorage.removeItem('hopscotch.test.storage');isStorageWritable=true;}}catch(err){}
|
||||||
|
defaultOpts={smoothScroll:true,scrollDuration:1000,scrollTopMargin:200,showCloseButton:true,showPrevButton:false,showNextButton:true,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:true,cookieName:'hopscotch.tour.state'};if(winHopscotch){return;}
|
||||||
|
if(!Array.isArray){Array.isArray=function(obj){return Object.prototype.toString.call(obj)==='[object Array]';};}
|
||||||
|
winLoadHandler=function(){if(waitingToStart){winHopscotch.startTour();}};utils={addClass:function(domEl,classToAdd){var domClasses,classToAddArr,setClass,i,len;if(!domEl.className){domEl.className=classToAdd;}
|
||||||
|
else{classToAddArr=classToAdd.split(/\s+/);domClasses=' '+ domEl.className+' ';for(i=0,len=classToAddArr.length;i<len;++i){if(domClasses.indexOf(' '+ classToAddArr[i]+' ')<0){domClasses+=classToAddArr[i]+' ';}}
|
||||||
|
domEl.className=domClasses.replace(/^\s+|\s+$/g,'');}},removeClass:function(domEl,classToRemove){var domClasses,classToRemoveArr,currClass,i,len;classToRemoveArr=classToRemove.split(/\s+/);domClasses=' '+ domEl.className+' ';for(i=0,len=classToRemoveArr.length;i<len;++i){domClasses=domClasses.replace(' '+ classToRemoveArr[i]+' ',' ');}
|
||||||
|
domEl.className=domClasses.replace(/^\s+|\s+$/g,'');},hasClass:function(domEl,classToCheck){var classes;if(!domEl.className){return false;}
|
||||||
|
classes=' '+ domEl.className+' ';return(classes.indexOf(' '+ classToCheck+' ')!==-1);},getPixelValue:function(val){var valType=typeof val;if(valType==='number'){return val;}
|
||||||
|
if(valType==='string'){return parseInt(val,10);}
|
||||||
|
return 0;},valOrDefault:function(val,valDefault){return typeof val!==undefinedStr?val:valDefault;},invokeCallbackArrayHelper:function(arr){var fn;if(Array.isArray(arr)){fn=helpers[arr[0]];if(typeof fn==='function'){return fn.apply(this,arr.slice(1));}}},invokeCallbackArray:function(arr){var i,len;if(Array.isArray(arr)){if(typeof arr[0]==='string'){return utils.invokeCallbackArrayHelper(arr);}
|
||||||
|
else{for(i=0,len=arr.length;i<len;++i){utils.invokeCallback(arr[i]);}}}},invokeCallback:function(cb){if(typeof cb==='function'){return cb();}
|
||||||
|
if(typeof cb==='string'&&helpers[cb]){return helpers[cb]();}
|
||||||
|
else{return utils.invokeCallbackArray(cb);}},invokeEventCallbacks:function(evtType,stepCb){var cbArr=callbacks[evtType],callback,fn,i,len;if(stepCb){return this.invokeCallback(stepCb);}
|
||||||
|
for(i=0,len=cbArr.length;i<len;++i){this.invokeCallback(cbArr[i].cb);}},getScrollTop:function(){var scrollTop;if(typeof window.pageYOffset!==undefinedStr){scrollTop=window.pageYOffset;}
|
||||||
|
else{scrollTop=document.documentElement.scrollTop;}
|
||||||
|
return scrollTop;},getScrollLeft:function(){var scrollLeft;if(typeof window.pageXOffset!==undefinedStr){scrollLeft=window.pageXOffset;}
|
||||||
|
else{scrollLeft=document.documentElement.scrollLeft;}
|
||||||
|
return scrollLeft;},getWindowHeight:function(){return window.innerHeight||document.documentElement.clientHeight;},getWindowWidth:function(){return window.innerWidth||document.documentElement.clientWidth;},addEvtListener:function(el,evtName,fn){return el.addEventListener?el.addEventListener(evtName,fn,false):el.attachEvent('on'+ evtName,fn);},removeEvtListener:function(el,evtName,fn){return el.removeEventListener?el.removeEventListener(evtName,fn,false):el.detachEvent('on'+ evtName,fn);},documentIsReady:function(){return document.readyState==='complete'||document.readyState==='interactive';},evtPreventDefault:function(evt){if(evt.preventDefault){evt.preventDefault();}
|
||||||
|
else if(event){event.returnValue=false;}},extend:function(obj1,obj2){var prop;for(prop in obj2){if(obj2.hasOwnProperty(prop)){obj1[prop]=obj2[prop];}}},getStepTargetHelper:function(target){var result=document.getElementById(target);if(result){return result;}
|
||||||
|
if(hasJquery){result=jQuery(target);return result.length?result[0]:null;}
|
||||||
|
if(Sizzle){result=new Sizzle(target);return result.length?result[0]:null;}
|
||||||
|
if(document.querySelector){try{return document.querySelector(target);}catch(err){}}
|
||||||
|
if(/^#[a-zA-Z][\w-_:.]*$/.test(target)){return document.getElementById(target.substring(1));}
|
||||||
|
return null;},getStepTarget:function(step){var queriedTarget;if(!step||!step.target){return null;}
|
||||||
|
if(typeof step.target==='string'){return utils.getStepTargetHelper(step.target);}
|
||||||
|
else if(Array.isArray(step.target)){var i,len;for(i=0,len=step.target.length;i<len;i++){if(typeof step.target[i]==='string'){queriedTarget=utils.getStepTargetHelper(step.target[i]);if(queriedTarget){return queriedTarget;}}}
|
||||||
|
return null;}
|
||||||
|
return step.target;},getI18NString:function(key){return customI18N[key]||HopscotchI18N[key];},setState:function(name,value,days){var expires='',date;if(hasSessionStorage&&isStorageWritable){try{sessionStorage.setItem(name,value);}
|
||||||
|
catch(err){isStorageWritable=false;this.setState(name,value,days);}}
|
||||||
|
else{if(hasSessionStorage){sessionStorage.removeItem(name);}
|
||||||
|
if(days){date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires='; expires='+date.toGMTString();}
|
||||||
|
document.cookie=name+'='+value+expires+'; path=/';}},getState:function(name){var nameEQ=name+'=',ca=document.cookie.split(';'),i,c,state;if(hasSessionStorage){state=sessionStorage.getItem(name);if(state){return state;}}
|
||||||
|
for(i=0;i<ca.length;i++){c=ca[i];while(c.charAt(0)===' '){c=c.substring(1,c.length);}
|
||||||
|
if(c.indexOf(nameEQ)===0){state=c.substring(nameEQ.length,c.length);break;}}
|
||||||
|
return state;},clearState:function(name){if(hasSessionStorage){sessionStorage.removeItem(name);}
|
||||||
|
else{this.setState(name,'',-1);}}};utils.addEvtListener(window,'load',winLoadHandler);callbacks={next:[],prev:[],start:[],end:[],show:[],error:[],close:[]};helpers={};HopscotchI18N={stepNums:null,nextBtn:'Next',prevBtn:'Back',doneBtn:'Done',skipBtn:'Skip',closeTooltip:'Close'};customI18N={};HopscotchBubble=function(opt){this.init(opt);};HopscotchBubble.prototype={isShowing:false,currStep:undefined,setPosition:function(step){var bubbleBoundingHeight,bubbleBoundingWidth,boundingRect,top,left,arrowOffset,targetEl=utils.getStepTarget(step),el=this.element,arrowEl=this.arrowEl;bubbleBoundingWidth=el.offsetWidth;bubbleBoundingHeight=el.offsetHeight;utils.removeClass(el,'fade-in-down fade-in-up fade-in-left fade-in-right');if(!step.placement&&step.orientation){step.placement=step.orientation;}
|
||||||
|
boundingRect=targetEl.getBoundingClientRect();if(step.placement==='top'){top=(boundingRect.top- bubbleBoundingHeight)- this.opt.arrowWidth;left=boundingRect.left;}
|
||||||
|
else if(step.placement==='bottom'){top=boundingRect.bottom+ this.opt.arrowWidth;left=boundingRect.left;}
|
||||||
|
else if(step.placement==='left'){top=boundingRect.top;left=boundingRect.left- bubbleBoundingWidth- this.opt.arrowWidth;}
|
||||||
|
else if(step.placement==='right'){top=boundingRect.top;left=boundingRect.right+ this.opt.arrowWidth;}
|
||||||
|
else{throw'Bubble placement failed because step.placement is invalid or undefined!';}
|
||||||
|
if(step.arrowOffset!=='center'){arrowOffset=utils.getPixelValue(step.arrowOffset);}
|
||||||
|
else{arrowOffset=step.arrowOffset;}
|
||||||
|
if(!arrowOffset){arrowEl.style.top='';arrowEl.style.left='';}
|
||||||
|
else if(step.placement==='top'||step.placement==='bottom'){arrowEl.style.top='';if(arrowOffset==='center'){arrowEl.style.left=Math.floor((bubbleBoundingWidth/2)- arrowEl.offsetWidth/2)+'px';}
|
||||||
|
else{arrowEl.style.left=arrowOffset+'px';}}
|
||||||
|
else if(step.placement==='left'||step.placement==='right'){arrowEl.style.left='';if(arrowOffset==='center'){arrowEl.style.top=Math.floor((bubbleBoundingHeight/2)- arrowEl.offsetHeight/2)+'px';}
|
||||||
|
else{arrowEl.style.top=arrowOffset+'px';}}
|
||||||
|
if(step.xOffset==='center'){left=(boundingRect.left+ targetEl.offsetWidth/2)-(bubbleBoundingWidth/2);}
|
||||||
|
else{left+=utils.getPixelValue(step.xOffset);}
|
||||||
|
if(step.yOffset==='center'){top=(boundingRect.top+ targetEl.offsetHeight/2)-(bubbleBoundingHeight/2);}
|
||||||
|
else{top+=utils.getPixelValue(step.yOffset);}
|
||||||
|
if(!step.fixedElement){top+=utils.getScrollTop();left+=utils.getScrollLeft();}
|
||||||
|
el.style.position=(step.fixedElement?'fixed':'absolute');el.style.top=top+'px';el.style.left=left+'px';},render:function(step,idx,callback){var el=this.element,tourSpecificRenderer,customTourData,unsafe,currTour,totalSteps,nextBtnText,isLast,opts;if(step){this.currStep=step;}
|
||||||
|
else if(this.currStep){step=this.currStep;}
|
||||||
|
if(this.opt.isTourBubble){currTour=winHopscotch.getCurrTour();if(currTour){customTourData=currTour.customData;tourSpecificRenderer=currTour.customRenderer;unsafe=currTour.unsafe;if(Array.isArray(currTour.steps)){totalSteps=currTour.steps.length;isLast=(idx===totalSteps- 1);}}}else{customTourData=step.customData;tourSpecificRenderer=step.customRenderer;unsafe=step.unsafe;}
|
||||||
|
if(isLast){nextBtnText=utils.getI18NString('doneBtn');}else if(step.showSkip){nextBtnText=utils.getI18NString('skipBtn');}else{nextBtnText=utils.getI18NString('nextBtn');}
|
||||||
|
if(!step.placement&&step.orientation){step.placement=step.orientation;}
|
||||||
|
this.placement=step.placement;opts={i18n:{prevBtn:utils.getI18NString('prevBtn'),nextBtn:nextBtnText,closeTooltip:utils.getI18NString('closeTooltip'),stepNum:this._getStepI18nNum(idx),},buttons:{showPrev:(utils.valOrDefault(step.showPrevButton,this.opt.showPrevButton)&&(idx>0)),showNext:utils.valOrDefault(step.showNextButton,this.opt.showNextButton),showCTA:utils.valOrDefault((step.showCTAButton&&step.ctaLabel),false),ctaLabel:step.ctaLabel,showClose:utils.valOrDefault(this.opt.showCloseButton,true)},step:{num:idx,isLast:utils.valOrDefault(isLast,false),title:(step.title||''),content:(step.content||''),placement:step.placement,padding:utils.valOrDefault(step.padding,this.opt.bubblePadding),width:utils.getPixelValue(step.width)||this.opt.bubbleWidth,customData:(step.customData||{})},tour:{isTour:this.opt.isTourBubble,numSteps:totalSteps,unsafe:utils.valOrDefault(unsafe,false),customData:(customTourData||{})}};if(typeof tourSpecificRenderer==='function'){el.innerHTML=tourSpecificRenderer(opts);}
|
||||||
|
else if(typeof tourSpecificRenderer==='string'){if(!hopscotch.templates||(typeof hopscotch.templates[tourSpecificRenderer]!=='function')){throw'Bubble rendering failed - template "'+ tourSpecificRenderer+'" is not a function.';}
|
||||||
|
el.innerHTML=hopscotch.templates[tourSpecificRenderer](opts);}
|
||||||
|
else if(customRenderer){el.innerHTML=customRenderer(opts);}
|
||||||
|
else{if(!hopscotch.templates||(typeof hopscotch.templates[templateToUse]!=='function')){throw'Bubble rendering failed - template "'+ templateToUse+'" is not a function.';}
|
||||||
|
el.innerHTML=hopscotch.templates[templateToUse](opts);}
|
||||||
|
children=el.children;numChildren=children.length;for(i=0;i<numChildren;i++){node=children[i];if(utils.hasClass(node,'hopscotch-arrow')){this.arrowEl=node;}}
|
||||||
|
el.style.zIndex=(typeof step.zindex==='number')?step.zindex:'auto';this._setArrow(step.placement);this.hide(false);this.setPosition(step);if(callback){callback(!step.fixedElement);}
|
||||||
|
return this;},_getStepI18nNum:function(idx){var stepNumI18N=utils.getI18NString('stepNums');if(stepNumI18N&&idx<stepNumI18N.length){idx=stepNumI18N[idx];}
|
||||||
|
else{idx=idx+ 1;}
|
||||||
|
return idx;},_setArrow:function(orientation){utils.removeClass(this.arrowEl,'down up right left');if(orientation==='top'){utils.addClass(this.arrowEl,'down');}
|
||||||
|
else if(orientation==='bottom'){utils.addClass(this.arrowEl,'up');}
|
||||||
|
else if(orientation==='left'){utils.addClass(this.arrowEl,'right');}
|
||||||
|
else if(orientation==='right'){utils.addClass(this.arrowEl,'left');}},_getArrowDirection:function(){if(this.placement==='top'){return'down';}
|
||||||
|
if(this.placement==='bottom'){return'up';}
|
||||||
|
if(this.placement==='left'){return'right';}
|
||||||
|
if(this.placement==='right'){return'left';}},show:function(){var self=this,fadeClass='fade-in-'+ this._getArrowDirection(),fadeDur=1000;utils.removeClass(this.element,'hide');utils.addClass(this.element,fadeClass);setTimeout(function(){utils.removeClass(self.element,'invisible');},50);setTimeout(function(){utils.removeClass(self.element,fadeClass);},fadeDur);this.isShowing=true;return this;},hide:function(remove){var el=this.element;remove=utils.valOrDefault(remove,true);el.style.top='';el.style.left='';if(remove){utils.addClass(el,'hide');utils.removeClass(el,'invisible');}
|
||||||
|
else{utils.removeClass(el,'hide');utils.addClass(el,'invisible');}
|
||||||
|
utils.removeClass(el,'animate fade-in-up fade-in-down fade-in-right fade-in-left');this.isShowing=false;return this;},destroy:function(){var el=this.element;if(el){el.parentNode.removeChild(el);}
|
||||||
|
utils.removeEvtListener(el,'click',this.clickCb);},_handleBubbleClick:function(evt){var action;evt=evt||window.event;var targetElement=evt.target||evt.srcElement;function findMatchRecur(el){if(el===evt.currentTarget){return null;}
|
||||||
|
if(utils.hasClass(el,'hopscotch-cta')){return'cta';}
|
||||||
|
if(utils.hasClass(el,'hopscotch-next')){return'next';}
|
||||||
|
if(utils.hasClass(el,'hopscotch-prev')){return'prev';}
|
||||||
|
if(utils.hasClass(el,'hopscotch-close')){return'close';}
|
||||||
|
return findMatchRecur(el.parentElement);}
|
||||||
|
action=findMatchRecur(targetElement);if(action==='cta'){if(!this.opt.isTourBubble){winHopscotch.getCalloutManager().removeCallout(this.currStep.id);}
|
||||||
|
if(this.currStep.onCTA){utils.invokeCallback(this.currStep.onCTA);}}
|
||||||
|
else if(action==='next'){winHopscotch.nextStep(true);}
|
||||||
|
else if(action==='prev'){winHopscotch.prevStep(true);}
|
||||||
|
else if(action==='close'){if(this.opt.isTourBubble){var currStepNum=winHopscotch.getCurrStepNum(),currTour=winHopscotch.getCurrTour(),doEndCallback=(currStepNum===currTour.steps.length-1);utils.invokeEventCallbacks('close');winHopscotch.endTour(true,doEndCallback);}else{if(this.opt.onClose){utils.invokeCallback(this.opt.onClose);}
|
||||||
|
if(this.opt.id&&!this.opt.isTourBubble){winHopscotch.getCalloutManager().removeCallout(this.opt.id);}
|
||||||
|
else{this.destroy();}}
|
||||||
|
utils.evtPreventDefault(evt);}},init:function(initOpt){var el=document.createElement('div'),self=this,resizeCooldown=false,onWinResize,appendToBody,children,numChildren,node,i,opt;this.element=el;opt={showPrevButton:defaultOpts.showPrevButton,showNextButton:defaultOpts.showNextButton,bubbleWidth:defaultOpts.bubbleWidth,bubblePadding:defaultOpts.bubblePadding,arrowWidth:defaultOpts.arrowWidth,showNumber:true,isTourBubble:true};initOpt=(typeof initOpt===undefinedStr?{}:initOpt);utils.extend(opt,initOpt);this.opt=opt;el.className='hopscotch-bubble animated';if(!opt.isTourBubble){utils.addClass(el,'hopscotch-callout no-number');}
|
||||||
|
onWinResize=function(){if(resizeCooldown||!self.isShowing){return;}
|
||||||
|
resizeCooldown=true;setTimeout(function(){self.setPosition(self.currStep);resizeCooldown=false;},100);};utils.addEvtListener(window,'resize',onWinResize);this.clickCb=function(evt){self._handleBubbleClick(evt);};utils.addEvtListener(el,'click',this.clickCb);this.hide();if(utils.documentIsReady()){document.body.appendChild(el);}
|
||||||
|
else{if(document.addEventListener){appendToBody=function(){document.removeEventListener('DOMContentLoaded',appendToBody);window.removeEventListener('load',appendToBody);document.body.appendChild(el);};document.addEventListener('DOMContentLoaded',appendToBody,false);}
|
||||||
|
else{appendToBody=function(){if(document.readyState==='complete'){document.detachEvent('onreadystatechange',appendToBody);window.detachEvent('onload',appendToBody);document.body.appendChild(el);}};document.attachEvent('onreadystatechange',appendToBody);}
|
||||||
|
utils.addEvtListener(window,'load',appendToBody);}}};HopscotchCalloutManager=function(){var callouts={};this.createCallout=function(opt){var callout;if(opt.id){if(callouts[opt.id]){throw'Callout by that id already exists. Please choose a unique id.';}
|
||||||
|
opt.showNextButton=opt.showPrevButton=false;opt.isTourBubble=false;callout=new HopscotchBubble(opt);callouts[opt.id]=callout;if(opt.target){callout.render(opt,null,function(){callout.show();});}}
|
||||||
|
else{throw'Must specify a callout id.';}
|
||||||
|
return callout;};this.getCallout=function(id){return callouts[id];};this.removeAllCallouts=function(){var calloutId,callout;for(calloutId in callouts){if(callouts.hasOwnProperty(calloutId)){this.removeCallout(calloutId);}}};this.removeCallout=function(id){var callout=callouts[id];callouts[id]=null;if(!callout){return;}
|
||||||
|
callout.destroy();};};Hopscotch=function(initOptions){var self=this,bubble,calloutMgr,opt,currTour,currStepNum,cookieTourId,cookieTourStep,_configure,getBubble=function(setOptions){if(!bubble){bubble=new HopscotchBubble(opt);}
|
||||||
|
if(setOptions){utils.extend(bubble.opt,{bubblePadding:getOption('bubblePadding'),bubbleWidth:getOption('bubbleWidth'),showNextButton:getOption('showNextButton'),showPrevButton:getOption('showPrevButton'),showCloseButton:getOption('showCloseButton'),arrowWidth:getOption('arrowWidth')});}
|
||||||
|
return bubble;},getOption=function(name){if(typeof opt==='undefined'){return defaultOpts[name];}
|
||||||
|
return utils.valOrDefault(opt[name],defaultOpts[name]);},getCurrStep=function(){var step;if(currStepNum<0||currStepNum>=currTour.steps.length){step=null;}
|
||||||
|
else{step=currTour.steps[currStepNum];}
|
||||||
|
return step;},targetClickNextFn=function(){self.nextStep();},adjustWindowScroll=function(cb){var bubble=getBubble(),bubbleEl=bubble.element,bubbleTop=utils.getPixelValue(bubbleEl.style.top),bubbleBottom=bubbleTop+ utils.getPixelValue(bubbleEl.offsetHeight),targetEl=utils.getStepTarget(getCurrStep()),targetBounds=targetEl.getBoundingClientRect(),targetElTop=targetBounds.top+ utils.getScrollTop(),targetElBottom=targetBounds.bottom+ utils.getScrollTop(),targetTop=(bubbleTop<targetElTop)?bubbleTop:targetElTop,targetBottom=(bubbleBottom>targetElBottom)?bubbleBottom:targetElBottom,windowTop=utils.getScrollTop(),windowBottom=windowTop+ utils.getWindowHeight(),scrollToVal=targetTop- getOption('scrollTopMargin'),scrollEl,yuiAnim,yuiEase,direction,scrollIncr,scrollTimeout,scrollTimeoutFn;if(targetTop>=windowTop&&(targetTop<=windowTop+ getOption('scrollTopMargin')||targetBottom<=windowBottom)){if(cb){cb();}}
|
||||||
|
else if(!getOption('smoothScroll')){window.scrollTo(0,scrollToVal);if(cb){cb();}}
|
||||||
|
else{if(typeof YAHOO!==undefinedStr&&typeof YAHOO.env!==undefinedStr&&typeof YAHOO.env.ua!==undefinedStr&&typeof YAHOO.util!==undefinedStr&&typeof YAHOO.util.Scroll!==undefinedStr){scrollEl=YAHOO.env.ua.webkit?document.body:document.documentElement;yuiEase=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined;yuiAnim=new YAHOO.util.Scroll(scrollEl,{scroll:{to:[0,scrollToVal]}},getOption('scrollDuration')/1000, yuiEase);
|
||||||
|
yuiAnim.onComplete.subscribe(cb);yuiAnim.animate();}
|
||||||
|
else if(hasJquery){jQuery('body, html').animate({scrollTop:scrollToVal},getOption('scrollDuration'),cb);}
|
||||||
|
else{if(scrollToVal<0){scrollToVal=0;}
|
||||||
|
direction=(windowTop>targetTop)?-1:1;scrollIncr=Math.abs(windowTop- scrollToVal)/ (getOption('scrollDuration')/10);
|
||||||
|
scrollTimeoutFn=function(){var scrollTop=utils.getScrollTop(),scrollTarget=scrollTop+(direction*scrollIncr);if((direction>0&&scrollTarget>=scrollToVal)||(direction<0&&scrollTarget<=scrollToVal)){scrollTarget=scrollToVal;if(cb){cb();}
|
||||||
|
window.scrollTo(0,scrollTarget);return;}
|
||||||
|
window.scrollTo(0,scrollTarget);if(utils.getScrollTop()===scrollTop){if(cb){cb();}
|
||||||
|
return;}
|
||||||
|
setTimeout(scrollTimeoutFn,10);};scrollTimeoutFn();}}},goToStepWithTarget=function(direction,cb){var target,step,goToStepFn;if(currStepNum+ direction>=0&&currStepNum+ direction<currTour.steps.length){currStepNum+=direction;step=getCurrStep();goToStepFn=function(){target=utils.getStepTarget(step);if(target){cb(currStepNum);}
|
||||||
|
else{utils.invokeEventCallbacks('error');goToStepWithTarget(direction,cb);}};if(step.delay){setTimeout(goToStepFn,step.delay);}
|
||||||
|
else{goToStepFn();}}
|
||||||
|
else{cb(-1);}},changeStep=function(doCallbacks,direction){var bubble=getBubble(),self=this,step,origStep,wasMultiPage,changeStepCb;bubble.hide();doCallbacks=utils.valOrDefault(doCallbacks,true);step=getCurrStep();origStep=step;if(direction>0){wasMultiPage=origStep.multipage;}
|
||||||
|
else{wasMultiPage=(currStepNum>0&&currTour.steps[currStepNum-1].multipage);}
|
||||||
|
changeStepCb=function(stepNum){var doShowFollowingStep;if(stepNum===-1){return this.endTour(true);}
|
||||||
|
if(doCallbacks){if(direction>0){doShowFollowingStep=utils.invokeEventCallbacks('next',origStep.onNext);}
|
||||||
|
else{doShowFollowingStep=utils.invokeEventCallbacks('prev',origStep.onPrev);}}
|
||||||
|
if(stepNum!==currStepNum){return;}
|
||||||
|
if(wasMultiPage){utils.setState(getOption('cookieName'),currTour.id+':'+ currStepNum,1);return;}
|
||||||
|
doShowFollowingStep=utils.valOrDefault(doShowFollowingStep,true);if(doShowFollowingStep){this.showStep(stepNum);}
|
||||||
|
else{this.endTour(false);}};if(!wasMultiPage&&getOption('skipIfNoElement')){goToStepWithTarget(direction,function(stepNum){changeStepCb.call(self,stepNum);});}
|
||||||
|
else if(currStepNum+ direction>=0&&currStepNum+ direction<currTour.steps.length){currStepNum+=direction;step=getCurrStep();if(!utils.getStepTarget(step)&&!wasMultiPage){utils.invokeEventCallbacks('error');return this.endTour(true,false);}
|
||||||
|
changeStepCb.call(this,currStepNum);}
|
||||||
|
return this;},loadTour=function(tour){var tmpOpt={},prop,tourState,tourPair;for(prop in tour){if(tour.hasOwnProperty(prop)&&prop!=='id'&&prop!=='steps'){tmpOpt[prop]=tour[prop];}}
|
||||||
|
_configure.call(this,tmpOpt,true);tourState=utils.getState(getOption('cookieName'));if(tourState){tourPair=tourState.split(':');cookieTourId=tourPair[0];cookieTourStep=tourPair[1];cookieTourStep=parseInt(cookieTourStep,10);}
|
||||||
|
return this;},findStartingStep=function(startStepNum,cb){var step,target,stepNum;currStepNum=startStepNum||0;step=getCurrStep();target=utils.getStepTarget(step);if(target){cb(currStepNum);return;}
|
||||||
|
if(!target){utils.invokeEventCallbacks('error');if(getOption('skipIfNoElement')){goToStepWithTarget(1,cb);return;}
|
||||||
|
else{currStepNum=-1;cb(currStepNum);}}},showStepHelper=function(stepNum){var step=currTour.steps[stepNum],tourSteps=currTour.steps,numTourSteps=tourSteps.length,cookieVal=currTour.id+':'+ stepNum,bubble=getBubble(),targetEl=utils.getStepTarget(step),isLast,showBubble;showBubble=function(){bubble.show();utils.invokeEventCallbacks('show',step.onShow);};currStepNum=stepNum;bubble.hide(false);isLast=(stepNum===numTourSteps- 1);bubble.render(step,stepNum,function(adjustScroll){if(adjustScroll){adjustWindowScroll(showBubble);}
|
||||||
|
else{showBubble();}
|
||||||
|
if(step.nextOnTargetClick){utils.addEvtListener(targetEl,'click',targetClickNextFn);}});utils.setState(getOption('cookieName'),cookieVal,1);},init=function(initOptions){if(initOptions){this.configure(initOptions);}};this.getCalloutManager=function(){if(typeof calloutMgr===undefinedStr){calloutMgr=new HopscotchCalloutManager();}
|
||||||
|
return calloutMgr;};this.startTour=function(tour,stepNum){var bubble,currStepNum,self=this;if(!currTour){currTour=tour;loadTour.call(this,tour);}
|
||||||
|
if(typeof stepNum!==undefinedStr){if(stepNum>=currTour.steps.length){throw'Specified step number out of bounds.';}
|
||||||
|
currStepNum=stepNum;}
|
||||||
|
if(!utils.documentIsReady()){waitingToStart=true;return this;}
|
||||||
|
if(typeof currStepNum==="undefined"&&currTour.id===cookieTourId&&typeof cookieTourStep!==undefinedStr){currStepNum=cookieTourStep;}
|
||||||
|
else if(!currStepNum){currStepNum=0;}
|
||||||
|
findStartingStep(currStepNum,function(stepNum){var target=(stepNum!==-1)&&utils.getStepTarget(currTour.steps[stepNum]);if(!target){self.endTour(false,false);return;}
|
||||||
|
utils.invokeEventCallbacks('start');bubble=getBubble();bubble.hide(false);self.isActive=true;if(!utils.getStepTarget(getCurrStep())){utils.invokeEventCallbacks('error');if(getOption('skipIfNoElement')){self.nextStep(false);}}
|
||||||
|
else{self.showStep(stepNum);}});return this;};this.showStep=function(stepNum){var step=currTour.steps[stepNum];if(step.delay){setTimeout(function(){showStepHelper(stepNum);},step.delay);}
|
||||||
|
else{showStepHelper(stepNum);}
|
||||||
|
return this;};this.prevStep=function(doCallbacks){changeStep.call(this,doCallbacks,-1);return this;};this.nextStep=function(doCallbacks){var step=getCurrStep(),targetEl=utils.getStepTarget(step);if(step.nextOnTargetClick){utils.removeEvtListener(targetEl,'click',targetClickNextFn);}
|
||||||
|
changeStep.call(this,doCallbacks,1);return this;};this.endTour=function(clearState,doCallbacks){var bubble=getBubble();clearState=utils.valOrDefault(clearState,true);doCallbacks=utils.valOrDefault(doCallbacks,true);currStepNum=0;cookieTourStep=undefined;bubble.hide();if(clearState){utils.clearState(getOption('cookieName'));}
|
||||||
|
if(this.isActive){this.isActive=false;if(currTour&&doCallbacks){utils.invokeEventCallbacks('end');}}
|
||||||
|
this.removeCallbacks(null,true);this.resetDefaultOptions();currTour=null;return this;};this.getCurrTour=function(){return currTour;};this.getCurrTarget=function(){return utils.getStepTarget(getCurrStep());};this.getCurrStepNum=function(){return currStepNum;};this.refreshBubblePosition=function(){bubble.setPosition(getCurrStep());return this;};this.listen=function(evtType,cb,isTourCb){if(evtType){callbacks[evtType].push({cb:cb,fromTour:isTourCb});}
|
||||||
|
return this;};this.unlisten=function(evtType,cb){var evtCallbacks=callbacks[evtType],i,len;for(i=0,len=evtCallbacks.length;i<len;++i){if(evtCallbacks[i]===cb){evtCallbacks.splice(i,1);}}
|
||||||
|
return this;};this.removeCallbacks=function(evtName,tourOnly){var cbArr,i,len,evt;for(evt in callbacks){if(!evtName||evtName===evt){if(tourOnly){cbArr=callbacks[evt];for(i=0,len=cbArr.length;i<len;++i){if(cbArr[i].fromTour){cbArr.splice(i--,1);--len;}}}
|
||||||
|
else{callbacks[evt]=[];}}}
|
||||||
|
return this;};this.registerHelper=function(id,fn){if(typeof id==='string'&&typeof fn==='function'){helpers[id]=fn;}};this.unregisterHelper=function(id){helpers[id]=null;};this.invokeHelper=function(id){var args=[],i,len;for(i=1,len=arguments.length;i<len;++i){args.push(arguments[i]);}
|
||||||
|
if(helpers[id]){helpers[id].call(null,args);}};this.setCookieName=function(name){opt.cookieName=name;return this;};this.resetDefaultOptions=function(){opt={};return this;};this.resetDefaultI18N=function(){customI18N={};return this;};this.getState=function(){return utils.getState(getOption('cookieName'));};_configure=function(options,isTourOptions){var bubble,events=['next','prev','start','end','show','error','close'],eventPropName,callbackProp,i,len;if(!opt){this.resetDefaultOptions();}
|
||||||
|
utils.extend(opt,options);if(options){utils.extend(customI18N,options.i18n);}
|
||||||
|
for(i=0,len=events.length;i<len;++i){eventPropName='on'+ events[i].charAt(0).toUpperCase()+ events[i].substring(1);if(options[eventPropName]){this.listen(events[i],options[eventPropName],isTourOptions);}}
|
||||||
|
bubble=getBubble(true);return this;};this.configure=function(options){return _configure.call(this,options,false);};this.setRenderer=function(render){var typeOfRender=typeof render;if(typeOfRender==='string'){templateToUse=render;customRenderer=undefined;}
|
||||||
|
else if(typeOfRender==='function'){customRenderer=render;}
|
||||||
|
return this;};this.setEscaper=function(esc){if(typeof esc==='function'){customEscape=esc;}
|
||||||
|
return this;};init.call(this,initOptions);};winHopscotch=new Hopscotch();context[namespace]=winHopscotch;(function(){var _={};_.escape=function(str){if(customEscape){return customEscape(str);}
|
||||||
|
if(str==null)return'';return(''+ str).replace(new RegExp('[&<>"\']','g'),function(match){if(match=='&'){return'&'}
|
||||||
|
if(match=='<'){return'<'}
|
||||||
|
if(match=='>'){return'>'}
|
||||||
|
if(match=='"'){return'"'}
|
||||||
|
if(match=="'"){return'''}});}
|
||||||
|
this["hopscotch"]=this["hopscotch"]||{};this["hopscotch"]["templates"]=this["hopscotch"]["templates"]||{};this["hopscotch"]["templates"]["bubble_default"]=function(obj){obj||(obj={});var __t,__p='',__e=_.escape,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}
|
||||||
|
with(obj){function optEscape(str,unsafe){if(unsafe){return _.escape(str);}
|
||||||
|
return str;};__p+='\n<div class="hopscotch-bubble-container" style="width: '+
|
||||||
|
((__t=(step.width))==null?'':__t)+'px; padding: '+
|
||||||
|
((__t=(step.padding))==null?'':__t)+'px;">\n ';if(tour.isTour){;__p+='<span class="hopscotch-bubble-number">'+
|
||||||
|
((__t=(i18n.stepNum))==null?'':__t)+'</span>';};__p+='\n <div class="hopscotch-bubble-content">\n ';if(step.title!==''){;__p+='<h3 class="hopscotch-title">'+
|
||||||
|
((__t=(optEscape(step.title,tour.unsafe)))==null?'':__t)+'</h3>';};__p+='\n ';if(step.content!==''){;__p+='<div class="hopscotch-content">'+
|
||||||
|
((__t=(optEscape(step.content,tour.unsafe)))==null?'':__t)+'</div>';};__p+='\n </div>\n <div class="hopscotch-actions">\n ';if(buttons.showPrev){;__p+='<button class="btn btn-default hopscotch-prev">'+
|
||||||
|
((__t=(i18n.prevBtn))==null?'':__t)+'</button>';};__p+='\n ';if(buttons.showCTA){;__p+='<button class="btn btn-primary hopscotch-cta">'+
|
||||||
|
((__t=(buttons.ctaLabel))==null?'':__t)+'</button>';};__p+='\n ';if(buttons.showNext){;__p+='<button class="btn btn-primary hopscotch-next">'+
|
||||||
|
((__t=(i18n.nextBtn))==null?'':__t)+'</button>';};__p+='\n </div>\n ';if(buttons.showClose){;__p+='<a title="'+
|
||||||
|
((__t=(i18n.closeTooltip))==null?'':__t)+'" href="#" class="hopscotch-bubble-close hopscotch-close"><i class="fa fa-times"></i></a>';};__p+='\n</div>\n<div class="hopscotch-bubble-arrow-container hopscotch-arrow">\n <div class="hopscotch-bubble-arrow-border"></div>\n <div class="hopscotch-bubble-arrow"></div>\n</div>';}
|
||||||
|
return __p};}());}(window,'hopscotch'));
|
||||||
Reference in New Issue
Block a user