同步提交。

This commit is contained in:
iFish 2014-05-16 20:10:45 +08:00
parent 33207cb5dd
commit acd9532621
13 changed files with 613 additions and 408 deletions

View File

@ -32,7 +32,7 @@ namespace StationDataFileGenerator
//@bji|北京|BJP|0
var commonData = new Regex(@"@([a-z]+)\|([^\|]+)\|([^\|]+)\|([^\|@]+)\|([^\|@]+)\|([^\|@'""]+)", RegexOptions.IgnoreCase).Matches(commonDataText)
.Cast<Match>().Select(s => new { p = s.Groups[4].Value.ToLower(), n = s.Groups[2].Value.ToLower(), c = s.Groups[3].Value, s = int.Parse(s.Groups[6].Value), h = s.Groups[5].Value.ToLower() })
.GroupBy(s => char.ToUpper(s.h[0])).ToDictionary(s => s.Key, s => s.OrderBy(x => x.s).ToDictionary(x => x.c))
.GroupBy(s => GetCodeKey(s.h)).ToDictionary(s => s.Key, s => s.OrderBy(x => x.s).ToDictionary(x => x.c))
;
var popData = new Regex(@"@([a-z]+)\|([^\|]+)\|([^\|]+)\|([^\|@]+)", RegexOptions.IgnoreCase).Matches(popDataText)
.Cast<Match>().Select(s => s.Groups[3].Value).ToArray();
@ -44,5 +44,12 @@ namespace StationDataFileGenerator
Console.ReadKey();
}
static string _root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
static string[] _groupStrings = new[] { "A-E", "F-J", "K-O", "P-T", "U-Z" };
static string GetCodeKey(string code)
{
var fl = char.ToUpper(code[0]);
return _groupStrings.First(s => s[0] <= fl && s[2] >= fl);
}
}
}

View File

@ -164,6 +164,7 @@
<Content Include="images\ticket-submit-info-arrow.png" />
<Content Include="images\ticket-submit-qr.png" />
<Content Include="index.html" />
<Content Include="js\account\sessionMgr.js" />
<Content Include="js\account\LoginUser.js" />
<Content Include="js\boot.js" />
<Content Include="css\fa\fonts\fontawesome-webfont.eot" />
@ -186,6 +187,7 @@
<Content Include="js\modules\jquery\jquery.js" />
<Content Include="js\modules\seajs\sea.js" />
<Content Include="js\modules\underscore\underscore.js" />
<Content Include="js\ui\ui-login.js" />
<Content Include="js\ui\widget.js" />
<Content Include="js\ui\widget_cityselector.js" />
<Content Include="js\ui\widget_datedropdown.js" />

View File

@ -1,282 +1,284 @@
body,
ul,
li,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
nav,
section,
summary,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
menu {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
box-sizing: content-box;
}
ol,
ul,
li {
list-style: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body {
line-height: 1;
background: url(../images/page-bg.png) repeat-x top left;
font: 14px Helvetica, Arial, "Microsoft Yahei", SimSun, sans-serif;
}
.cl {
zoom: 1;
content: '';
}
.cl:after {
display: block;
clear: both;
content: "";
visibility: hidden;
height: 0;
}
input:focus,
textarea:focus {
outline: none;
}
img {
border: 0 none;
}
a:link,
a:visited,
a:hover,
a:active {
color: #333;
text-decoration: none;
}
/**通用**/
.wrap {
width: 982px;
margin: 0 auto;
}
.pr {
position: relative;
}
.fl {
float: left;
}
.fr {
float: right;
}
.offset-parent {
position: relative;
}
/*通用顶部*/
.header-bar {
height: 87px;
}
.header-bar .logo {
width: 184px;
height: 49px;
margin: 21px 0 0 8px;
float: left;
}
.header-bar .user-nav {
margin-top: 9px;
float: right;
/**************导航tab对应icon 开始 *********************/
/**************导航tab对应icon 结束*********************/
}
.header-bar .user-nav .icon-index {
width: 23px;
background-position: 0 0;
}
.header-bar .user-nav .icon-order {
width: 26px;
background-position: 0 -44px;
}
.header-bar .user-nav .icon-12306 {
width: 24px;
background-position: 0 -84px;
}
.header-bar .user-nav .icon-user {
width: 24px;
background-position: 0 -122px;
}
.header-bar .user-nav li {
padding-top: 16px;
width: 104px;
height: 65px;
text-align: center;
color: #fff;
float: left;
cursor: pointer;
position: relative;
}
.header-bar .user-nav li:after {
content: '';
width: 1px;
height: 50px;
background-color: #d26405;
position: absolute;
top: 10px;
right: -1px;
}
.header-bar .user-nav li .icon {
display: inline-block;
height: 26px;
margin-bottom: 2px;
}
.header-bar .user-nav li.selected {
border-radius: 5px;
color: #f17206;
background: #fff;
padding-bottom: 10px;
}
.header-bar .user-nav li:hover div,
.header-bar .user-nav li:hover p,
.header-bar .user-nav li:hover i {
opacity: 0.75;
}
.header-bar .user-nav li:active div,
.header-bar .user-nav li:active p,
.header-bar .user-nav li:active i {
opacity: 0.4;
}
.header-bar .user-nav li.selected .icon-index {
background-position: 0 -164px;
}
.header-bar .user-nav li.selected .icon-order {
background-position: 0 -207px;
}
.header-bar .user-nav li.selected .icon-12306 {
background-position: 0 -45px;
}
.header-bar .user-nav li.selected .icon-user {
background-position: 0 -284px;
}
.header-bar .user-nav .user-nav-user {
position: relative;
width: 50px;
margin: 0 auto;
}
.header-bar .user-nav .user-nav-user:after {
content: '';
border-top: 5px solid #fff;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
width: 0;
height: 0;
position: absolute;
right: -8px;
top: 7px;
}
.header-bar .user-nav li .user-nav-menu {
background-color: #fff;
margin: 0;
border: 1px solid #c8c7c7;
border-radius: 4px;
position: relative;
top: 0;
box-shadow: 3px 3px 5px rgba(150,150,150,0.2);
z-index: 100;
display: none;
transition: linear all 0.2s;
padding-top: 5px;
padding-bottom: 5px;
}
.header-bar .user-nav li:hover .user-nav-menu {
transition: linear all 0.2s;
top: 6px;
display: block;
}
.header-bar .user-nav .user-nav-menu dd {
margin-left: 0;
}
.header-bar .user-nav .user-nav-menu a {
display: block;
padding: 10px;
}
.header-bar .user-nav .user-nav-menu a:hover {
background-color: #fff0d9;
}
.header-bar .user-nav .user-nav-menu a:active {
background-color: #f7f1e8;
}
input[type="checkbox"] {
margin-left: 12px;
width: 15px;
height: 15px;
border: 0;
-webkit-appearance: none;
border-radius: 3px;
display: inline-block;
margin-bottom: 0;
margin-top: 0;
position: relative;
vertical-align: middle;
background: url(../images/icon.png) no-repeat 0 -560px;
}
input[type="checkbox"]:checked {
background-position: 0 -582px;
}
body,
ul,
li,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
nav,
section,
summary,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
menu {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
box-sizing: content-box;
}
ol,
ul,
li {
list-style: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body {
line-height: 1;
background: url(../images/page-bg.png) repeat-x top left;
font: 14px Helvetica, Arial, "Microsoft Yahei", SimSun, sans-serif;
}
.cl {
zoom: 1;
content: '';
}
.cl:after {
display: block;
clear: both;
content: "";
visibility: hidden;
height: 0;
}
input:focus,
textarea:focus {
outline: none;
}
img {
border: 0 none;
}
a:link,
a:visited,
a:hover,
a:active {
color: #333;
text-decoration: none;
}
/**通用**/
.wrap {
width: 982px;
margin: 0 auto;
}
.pr {
position: relative;
}
.fl {
float: left;
}
.fr {
float: right;
}
.offset-parent {
position: relative;
}
/*通用顶部*/
.header-bar {
height: 87px;
}
.header-bar .logo {
width: 184px;
height: 49px;
margin: 21px 0 0 8px;
float: left;
}
.header-bar .user-nav {
margin-top: 9px;
float: right;
/**************导航tab对应icon 开始 *********************/
/**************导航tab对应icon 结束*********************/
}
.header-bar .user-nav .icon-index {
width: 23px;
background-position: 0 0;
}
.header-bar .user-nav .icon-order {
width: 26px;
background-position: 0 -44px;
}
.header-bar .user-nav .icon-12306 {
width: 24px;
background-position: 0 -84px;
}
.header-bar .user-nav .icon-user {
width: 24px;
background-position: 0 -122px;
}
.header-bar .user-nav li {
padding-top: 16px;
width: 104px;
height: 65px;
text-align: center;
color: #fff;
float: left;
cursor: pointer;
position: relative;
}
.header-bar .user-nav li > a {
color: #fff;
}
.header-bar .user-nav li:after {
content: '';
width: 1px;
height: 50px;
background-color: #d26405;
position: absolute;
top: 10px;
right: -1px;
}
.header-bar .user-nav li .icon {
display: inline-block;
height: 26px;
margin-bottom: 2px;
}
.header-bar .user-nav li.selected {
border-radius: 5px;
color: #f17206;
background: #fff;
padding-bottom: 10px;
}
.header-bar .user-nav li:hover div,
.header-bar .user-nav li:hover p,
.header-bar .user-nav li:hover i {
opacity: 0.75;
}
.header-bar .user-nav li:active div,
.header-bar .user-nav li:active p,
.header-bar .user-nav li:active i {
opacity: 0.4;
}
.header-bar .user-nav li.selected .icon-index {
background-position: 0 -164px;
}
.header-bar .user-nav li.selected .icon-order {
background-position: 0 -207px;
}
.header-bar .user-nav li.selected .icon-12306 {
background-position: 0 -45px;
}
.header-bar .user-nav li.selected .icon-user {
background-position: 0 -284px;
}
.header-bar .user-nav .user-nav-user {
position: relative;
width: 50px;
margin: 0 auto;
}
.header-bar .user-nav .user-nav-user:after {
content: '';
border-top: 5px solid #fff;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
width: 0;
height: 0;
position: absolute;
right: -8px;
top: 7px;
}
.header-bar .user-nav li .user-nav-menu {
background-color: #fff;
margin: 0;
border: 1px solid #c8c7c7;
border-radius: 4px;
position: relative;
top: 0;
box-shadow: 3px 3px 5px rgba(150,150,150,0.2);
z-index: 100;
display: none;
transition: linear all 0.2s;
padding-top: 5px;
padding-bottom: 5px;
}
.header-bar .user-nav li:hover .user-nav-menu {
transition: linear all 0.2s;
top: 6px;
display: block;
}
.header-bar .user-nav .user-nav-menu dd {
margin-left: 0;
}
.header-bar .user-nav .user-nav-menu a {
display: block;
padding: 10px;
}
.header-bar .user-nav .user-nav-menu a:hover {
background-color: #fff0d9;
}
.header-bar .user-nav .user-nav-menu a:active {
background-color: #f7f1e8;
}
input[type="checkbox"] {
margin-left: 12px;
width: 15px;
height: 15px;
border: 0;
-webkit-appearance: none;
border-radius: 3px;
display: inline-block;
margin-bottom: 0;
margin-top: 0;
position: relative;
vertical-align: middle;
background: url(../images/icon.png) no-repeat 0 -560px;
}
input[type="checkbox"]:checked {
background-position: 0 -582px;
}

View File

@ -1,7 +1,6 @@
/*城市选择*/
#citySelector {
#city_selector {
width: 400px;
height: 400px;
box-shadow: 3px 3px 10px rgba(110, 110, 110, 0.5);
background-color: #f5f6f5;
z-index: 100;
@ -9,25 +8,19 @@
display: none;
}
#citySelector.open,
#citySelector:hover {
#city_selector.open,
#city_selector:hover {
display: block;
}
#citySelector .allCityList {
width: 100%;
height: 100%;
position: relative;
}
#citySelector .allCityList .city-recently-used {
#city_selector .city-tab-nav {
width: 100%;
height: 48px;
background: linear-gradient(to top, #f66d07, #fc9803);
font-size: 12px;
}
#citySelector .allCityList .city-recently-used li {
#city_selector .city-tab-nav li {
float: left;
width: 50px;
box-sizing: border-box;
@ -40,25 +33,25 @@
font-weight: bold;
}
#citySelector .allCityList .city-recently-used li:hover,
#citySelector .allCityList .city-recently-used li.selected {
#city_selector .city-tab-nav li:hover,
#city_selector .city-tab-nav li.selected {
background: #fff linear-gradient(to top, #f1f1f1, #ffffff);
background: #fff -moz-linear-gradient(to top, #f1f1f1, #ffffff);
color: #f17206;
}
#citySelector .allCityList .common p {
#city_selector p {
padding: 14px 0 10px 30px;
font-weight: bold;
color: #74848d;
}
#citySelector .allCityList .common .commonCityList {
#city_selector .recent-city-list dl {
margin: 0 12px 12px 12px;
overflow: hidden;
}
#citySelector .allCityList .common .commonCityList dd {
#city_selector .recent-city-list dd {
margin: 0;
border: 1px solid #d0d0d0;
border-radius: 4px;
@ -71,25 +64,25 @@
cursor: pointer;
}
#citySelector .allCityList .common .commonCityList dd:hover {
#city_selector .recent-city-list dd:hover {
background-color: #ff9b00;
color: #ffffff;
}
#citySelector .allCityList .common .commonCityList dd + dd {
#city_selector .recent-city-list dd + dd {
margin-left: 7px;
}
#citySelector .allCityList .cityList {
border-left: 1px solid #e1e1e1;
margin: 0 12px 12px 12px;
#city_selector .city-list-container {
margin: 0 auto 50px auto;
overflow: hidden;
color: #7b848d;
border-right: 1px solid #e1e1e1;
border-bottom: 1px solid #e1e1e1;
width: 390px;
}
#citySelector .allCityList .cityList li {
#city_selector .city-list-container li {
float: left;
width: 25%;
line-height: 35px;
@ -100,17 +93,21 @@
cursor: pointer;
}
#citySelector .allCityList .cityList li:hover {
#city_selector .city-list-container li:hover {
background-color: #ff9b00;
color: white;
}
#citySelector .allCityList .cityList li:active {
#city_selector .city-list-container li:active {
background-color: #f78800;
color: white;
}
#citySelector .allCityList .cityPager {
#city_selector .city-search {
display: none;
}
#city_selector .city-list-pager {
position: absolute;
bottom: 0;
left: 0;
@ -119,7 +116,7 @@
width: 100%;
}
#citySelector .allCityList .cityPager button {
#city_selector .city-list-pager button {
line-height: 24px;
background: linear-gradient(0, #e6e6e6, #f9f9f9);
color: #7d848d;
@ -128,11 +125,11 @@
cursor: pointer;
}
#citySelector .allCityList .cityPager button:hover {
#city_selector .city-list-pager button:hover {
background: linear-gradient(to top, #efefef, #ffffff);
}
#citySelector .allCityList .cityPager button:disabled {
#city_selector .city-list-pager button:disabled {
border: 1px solid transparent;
background: none transparent;
color: #9da2a8;

View File

@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<title>12306订票助手</title>
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>
<body>
@ -16,12 +16,16 @@
<p>抢票首页</p>
</li>
<li>
<i class="icon icon-order"></i>
<p>我的订单</p>
<a href="https://kyfw.12306.cn/otn/queryOrder/init" target="_blank">
<i class="icon icon-order"></i>
<p>我的订单</p>
</a>
</li>
<li>
<i class="icon icon-12306"></i>
<p>访问12306</p>
<a href="https://kyfw.12306.cn/otn/" target="_blank">
<i class="icon icon-12306"></i>
<p>访问12306</p>
</a>
</li>
<li>
<i class="icon icon-user"></i>
@ -30,10 +34,10 @@
</div>
<dl class="user-nav-menu">
<dd>
<a href="#">登录账号</a>
<a href="#">注册新账号</a>
<a href="#">忘记密码</a>
<a href="#">退出账号</a>
<a href="javascript:;" target="acc_login">登录账号</a>
<a href="https://kyfw.12306.cn/otn/regist/init" target="_blank">注册新账号</a>
<a href="https://kyfw.12306.cn/otn/forgetPassword/initforgetMyPassword" target="_blank">忘记密码</a>
<a href="javascript:;" id="acc_logout">退出账号</a>
</dd>
</dl>
</li>
@ -383,7 +387,7 @@
</div>
<article id="save-travel-method" class="float-dialog">
<header>
新建出行计划

View File

@ -0,0 +1,30 @@
define(function (require, exports, module) {
var session = null;
var ev = require("../platform/EventObject.js");
//var LoginUser = require("./LoginUser.js");
var SessionMgr = function () {
var that = this;
ev.apply(this, arguments);
Object.defineProperty(this, "current", {
get: function () {
return session;
},
set:function(v) {
if (session === v) return;
session = v;
that.fireEvent("sessionChanged");
}
});
return this;
};
SessionMgr.prototype = Object.create(ev);
SessionMgr.constructor = SessionMgr;
module.exports = new SessionMgr();
});

View File

@ -1,32 +1,43 @@
//12306入口引导脚本
(function (window, document) {
var basePath = window.location.protocol + "//" + window.location.host + "/js/";
var pagename = /\/(\w+?)\.html/.exec(location.pathname) && RegExp.$1 || "index";
var loadScript = function (path, callback) {
var script = document.createElement("script");
script.src = basePath + path;
script.onload = function () {
callback();
document.head.removeChild(script);
};
document.head.appendChild(script);
};
loadScript("modules/seajs/sea.js", function () {
seajs.config({
base: basePath,
alias: {
"jquery": "modules/jquery/jquery.js",
"underscore": "modules/underscore/underscore.js"
},
vars: {
'locale': 'zh-cn'
},
charset: "utf-8",
debug: true
});
seajs.use("ui/" + pagename);
});
})(window, document);
//12306入口引导脚本
(function (window, document) {
var basePath = window.location.protocol + "//" + window.location.host + "/js/";
var pagename = /\/(\w+?)\.html/.exec(location.pathname) && RegExp.$1 || "index";
var loadScript = function (path, callback) {
var script = document.createElement("script");
script.src = basePath + path;
script.onload = function () {
callback();
document.head.removeChild(script);
};
document.head.appendChild(script);
};
//extend underscore
_.mixin({
mapObject: function (array, keySelector) {
var obj = {};
_.each(array, function (e) {
obj[keySelector(e)] = e;
});
return obj;
}
});
loadScript("modules/seajs/sea.js", function () {
seajs.config({
base: basePath,
alias: {
"jquery": "modules/jquery/jquery.js",
"underscore": "modules/underscore/underscore.js"
},
vars: {
'locale': 'zh-cn'
},
charset: "utf-8",
debug: true
});
seajs.use("ui/" + pagename);
});
})(window, document);

View File

@ -1,43 +1,41 @@
define(function (require, exports, module) {
var _ = require("./modules/underscore/underscore.js");
exports.identityCardTypes = {
};
exports.passengerTypes = {
"1": "成人",
"2": "儿童",
"3": "学生",
"4": "残疾军人、伤残人民警察"
};
exports.tagOtnMap = {
"9": "SWZ",
"P": "TZ",
"M": "ZY",
"O": "ZE",
"6": "GR",
"4": "RW",
"3": "YW",
"2": "RZ",
"1": "YZ",
"0": "WZ",
"*": "QT"
};
exports.tagRevMap = _.invert(exports.tagOtnMap);
exports.seatNameMap = {
"商务座": "SWZ",
"特等座": "TZ",
"一等座": "ZY",
"二等座": "ZE",
"高级软卧": "GR",
"软卧": "RW",
"硬卧": "YW",
"软座": "RZ",
"硬座": "YZ",
"无座": "WZ"
};
exports.seatNameInvMap = _.invert(exports.seatNameMap);
exports.baseUri = "https://kyfw.12306.cn/otn/";
exports.queryBaseUri = "https://dynamic.12306.cn/otsquery/";
define(function (require, exports, module) {
exports.identityCardTypes = {
};
exports.passengerTypes = {
"1": "成人",
"2": "儿童",
"3": "学生",
"4": "残疾军人、伤残人民警察"
};
exports.tagOtnMap = {
"9": "SWZ",
"P": "TZ",
"M": "ZY",
"O": "ZE",
"6": "GR",
"4": "RW",
"3": "YW",
"2": "RZ",
"1": "YZ",
"0": "WZ",
"*": "QT"
};
exports.tagRevMap = _.invert(exports.tagOtnMap);
exports.seatNameMap = {
"商务座": "SWZ",
"特等座": "TZ",
"一等座": "ZY",
"二等座": "ZE",
"高级软卧": "GR",
"软卧": "RW",
"硬卧": "YW",
"软座": "RZ",
"硬座": "YZ",
"无座": "WZ"
};
exports.seatNameInvMap = _.invert(exports.seatNameMap);
exports.baseUri = "https://kyfw.12306.cn/otn/";
exports.queryBaseUri = "https://dynamic.12306.cn/otsquery/";
});

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,9 @@
require("./widget_datedropdown.js").init("input.ui-date");
require("./widget_cityselector.js").init("input.ui-cityselector");
//加载各模块
var ui_login = require("./ui-login.js");
setTimeout(function () {
}, 1000);
});

View File

@ -0,0 +1,19 @@
define(function(require, exports, module) {
var sessionMgr = require("../account/sessionMgr.js");
var ev = require("../platform/EventObject.js");
var UiWidgetLogin = function() {
ev.appy(this, arguments);
};
UiWidgetLogin.prototype = Object.create(ev);
UiWidgetLogin.constructor = UiWidgetLogin;
sessionMgr.on("sessionChanged", function() {
});
});

View File

@ -1,37 +1,169 @@
define(function(require, exports) {
var $html = '<div id="citySelector"><div class="allCityList"><ul class="city-recently-used"><li class="selected">常用</li><li>A-E</li><li>F-J</li><li>K-O</li><li>P-T</li><li>U-Z</li></ul><div class="common"><p>常用城市</p><dl class="commonCityList"></dl></div><ul class="cityList"></ul><div class="cityPager"><button class="city-prev" disabled="disabled">上一页</button><button class="city-next">下一页</button></div></div></div>';
define(function (require, exports) {
var $html = '<div id="city_selector"><ul class="city-tab-nav"><li class="selected">常用</li><li data-code="A-E">A-E</li><li data-code="F-J">F-J</li><li data-code="K-O">K-O</li><li data-code="P-T">P-T</li><li data-code="U-Z">U-Z</li></ul><div class="recent-city-list"><p>最近查询</p><dl></dl></div><div class="city-pop"><p>常用城市</p><ul class="city-list-container"></ul></div><div class="city-search"><p>站点列表</p><ul class="city-list-container"></ul><div class="city-list-pager"><button class="city-prev" disabled="disabled">上一页</button><button class="city-next">下一页</button></div></div></div>';
var selector;
var divCity;
var data = require("../station/station_data.js");
var CitySelector = function(options) {
var cityMap = _(_.flatten(_.map(_.values(data.data), function (e) { return _.values(e); }))).mapObject(function (e) { return e.c; });
var CitySelector = function (options) {
var that = this;
var dom = $("#city_selector");
var currentList = null;
var currentPage = 1;
var totalPage = 1;
var pageSize = options.rows * 4;
var target = null;
var prevTab = null;
that.showPopup = function(ele) {
$(document).keydown("#city_selector", function() {
if (target)
target[0].focus();
});
that.performSearch = function () {
var key = target.val().replace(/\s/g, "");
if (!key) {
that.switchTab(prevTab);
return;
}
//清空选择
that.switchTab();
dom.find(".city-search").show().find(">p").html("搜索“" + key + "”");
//搜索城市
key = key.toUpperCase();
var lkey = key.toLowerCase();
currentList = _.filter(_.values(cityMap), function(e) {
return e.p.indexOf(lkey) != -1 ||
e.n.indexOf(key) != -1 ||
e.c.indexOf(key) != -1 ||
e.h.indexOf(lkey) != -1;
});
currentPage = 0;
totalPage = Math.ceil(currentList.length / pageSize);
that.renderPage(1);
};
that.showPopup = function (ele) {
that.switchTab(dom.find(".city-tab-nav li:first"));
var offset = ele.offset();
divCity.css({ left: offset.left + "px", top: (offset.top + ele.height()) + "px" });
divCity.addClass("open");
target = ele;
target.bind("keyup", that.performSearch);
};
that.hidePopup = function() {
that.hidePopup = function () {
if (target) {
target.unbind("keyup", that.performSearch);
//target = null;
}
divCity.removeClass("open");
};
that.switchTab = function (tab) {
dom.find(".city-tab-nav li").removeClass("selected");
dom.find(".city-search, .city-pop, .recent-city-list").hide();
if (!tab)
return;
tab.addClass("selected");
prevTab = tab;
var code = tab.attr("data-code");
currentPage = 0;
if (code) {
dom.find(".city-search>p").html("站点列表");
currentList = _.values(data.data[code]);
totalPage = Math.ceil(currentList.length / pageSize);
that.renderPage(1);
dom.find(".city-search").show();
} else {
currentList = null;
dom.find(".city-pop, .recent-city-list").show();
}
};
that.renderPage = function (page) {
/// <summary>切换当前的分页</summary>
if (page < 1 || page === currentPage || page > totalPage)
return;
currentPage = page;
//绑定数据
var html = [];
var listCount = 0;
for (var i = (currentPage - 1) * pageSize; i < currentPage * pageSize && i < currentList.length; i++) {
var city = currentList[i];
listCount++;
html.push("<li data-code='" + city.c + "' data-py='" + city.p + "' data-name='" + city.n + "' data-fl='" + city.h + "'>" + city.n + "</li>");
}
if (listCount % 4 !== 0) {
for (var i = 0; i < 4 - listCount % 4; i++) {
html.push("<li></li>");
}
}
dom.find(".city-search ul").empty().append(html.join(""));
//上一页下一页可用性
$("button.city-prev")[0].disabled = currentPage <= 1;
$("button.city-next")[0].disabled = currentPage >= totalPage - 1;
};
that.showNextPage = function () {
that.renderPage(currentPage + 1);
};
that.showPrevPage = function () {
that.renderPage(currentPage - 1);
};
dom.find("button.city-prev").click(that.showPrevPage);
dom.find("button.city-next").click(that.showNextPage);
return this;
};
exports.init = function(eleSelector, args) {
exports.init = function (eleSelector, args) {
$("body").append($html);
divCity = $("#citySelector");
divCity = $("#city_selector");
args = $.extend({}, args);
//初始化常用城市
(function () {
var html = [];
_.each(data.popcity, function (c) {
var city = cityMap[c];
html.push("<li data-code='" + city.c + "' data-py='" + city.p + "' data-name='" + city.n + "' data-fl='" + city.h + "'>" + city.n + "</li>");
});
if (data.popcity.length % 4 !== 0) {
for (var i = 0; i < 4 - data.popcity.length % 4; i++) {
html.push("<li></li>");
}
}
$("#city_selector .city-pop ul").append(html.join(""));
})();
args = $.extend({ rows: 9 }, args);
selector = new CitySelector(args);
$(document).on("focus", eleSelector, function () {
selector.showPopup($(this));
}).on("blur", eleSelector, function () {
selector.hidePopup($(this));
});
divCity.find(".city-tab-nav li").click(function () {
var tab = $(this);
if (tab.hasClass("selected"))
return;
selector.switchTab(tab);
});
};
});

View File

@ -117,7 +117,7 @@
if (cell.hasClass("date-notavailable") || !container.data("date-target")) return;
var target = container.data("date-target").val(cell.attr("data-date"));
target.trigger("datechanged.widget.ui.datepopup");
target.trigger("datechanged.widget.ui.datepopup").change();
dropdownInstance.hidePopup();
container.removeData("date-target");
@ -131,7 +131,7 @@
params = $.extend({
maxSellDays: 20,
maxSellDays: 19,
selectDate: [],
minDate: getCurDate()
}, params);