Skip to content

Commit d67b084

Browse files
author
jikeytang
committed
update
1 parent 7a3321d commit d67b084

File tree

1 file changed

+110
-57
lines changed

1 file changed

+110
-57
lines changed

c/7/index.html

Lines changed: 110 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,63 @@
1212
body{font:12px/1.125 Microsoft YaHei;background:#fff;}
1313
ul,li{list-style:none;}
1414
a{text-decoration:none;}
15-
.wrap{width:400px;height:350px;text-align:center;margin:150px auto;}
15+
.wrap{width:580px;height:350px;text-align:center;margin:150px auto;}
1616
.wrap .btn{margin:0 10px;padding:8px 40px;}
1717
.inner{padding:15px;}
1818
.clearfix{overflow:hidden;_zoom:1;}
1919
.none{display:none;}
20+
.color-panle{display:none;width:199px;background:#fff;}
21+
.color-list{border-top:1px solid #000;border-left:1px solid #000;}
22+
.color-list ul{float:left;width:66px;height:66px;margin:0;padding:0;}
23+
.color-list li{list-style:none;float:left;width:10px;height:10px;border-bottom:1px solid #000;border-right:1px solid #000;overflow:hidden;cursor:pointer;}
24+
.color-read{padding-bottom:5px;height:15px;}
25+
.color-read .color-val{float:right;}
26+
.color-read .color-show{float:left;width:50px;height:15px;border:1px solid #000;}
2027
</style>
21-
<link rel="stylesheet" id="style" href="css/blue.css">
2228
</head>
2329
<body>
2430
<div class="wrap">
25-
<div class="demo" id="div">
31+
<div class="demo" id="container">
2632
<input type="text" name="" size="60" id="input" class="input input-lg">
33+
2734
</div>
2835
</div>
2936
<div style="display:none;">
3037
<div id="div" style="width:100px;height:200px;background:#000;"></div>
3138
<button id="btn">test</button>
3239
</div>
40+
<script type="text/html" id="tpl-list">
41+
<% for (var i = 0; i < data.length; i++){%>
42+
<ul>
43+
<% for ( var j = 0; j < data[i].length; j++ ) { %>
44+
<li style="background-color:#<%=data[i][j]%>"></li>
45+
<% } %>
46+
</ul>
47+
<%}%>
48+
</script>
3349
<script>
3450
(function(){
3551
var div = document.getElementById('div')
3652
var btn = div.getElementsByTagName('button')
3753
var style = document.getElementById('style')
3854
var css = ['blue.css', 'yellow.css', 'green.css']
3955

40-
function init(){
41-
var href = getCookie('css')
42-
if(href.length){
43-
setStyle(href)
44-
}
45-
}
46-
47-
init()
48-
4956
var dog = {
5057
$ : function(selector){
51-
return document.querySelector(selector);
58+
return document.querySelector(selector)
5259
},
5360
on: function(el, type, handler){
54-
el.addEventListener(type, handler, false);
61+
el.addEventListener(type, handler, false)
5562
},
5663
off: function(el, type, handler){
57-
el.removeEventListener(type, handler);
64+
el.removeEventListener(type, handler)
5865
},
5966
position : function(obj, attr){
6067
if(obj){
61-
var method = obj.getBoundingClientRect();
62-
return attr ? method[attr] : method;
68+
var method = obj.getBoundingClientRect()
69+
return attr ? method[attr] : method
6370
} else {
64-
console.log('对象不存在!');
71+
console.log('对象不存在!')
6572
}
6673
},
6774
cache : {},
@@ -77,9 +84,9 @@
7784
.split("\t").join("';")
7885
.split("%>").join("p+='")
7986
.split("\r").join("\\'")
80-
+"';return p;");
87+
+"';return p;")
8188

82-
return data? fn.call(data):fn;
89+
return data ? fn.call(data) : fn
8390
},
8491
setCookie : function(key, value, day){
8592
var d = new Date()
@@ -91,87 +98,133 @@
9198
for (var i = 0; i < list.length; i++) {
9299
var one = list[i].split('=')
93100
if(one[0] == key){
94-
return one[1];
101+
return one[1]
95102
}
96103
};
97104
return ''
98105
},
99106
delCookies : function(key){
100107
this.setCookie(key, 1, -1)
108+
},
109+
show : function(obj){
110+
obj.style.display = 'block'
111+
},
112+
hide : function(obj){
113+
obj.style.display = 'none'
101114
}
102115
}
103116

104117
function Palette(){
105118
var args = arguments[0],
106-
dom = args.dom;
119+
dom = args.dom
107120

108121
for(var key in args){
109122
if(key == 'dom'){
110123
this.getDom(dom);
111124
} else {
112-
this[key] = args[key];
125+
this[key] = args[key]
113126
}
114127
}
115-
this.init();
128+
this.init()
116129
}
117130
Palette.prototype = {
118131
init : function(){
119-
this.render();
132+
this.render()
133+
},
134+
__dom : {
135+
__list : '.color-list'
120136
},
121137
setDom : function(){
122-
this.getDom(this._dom);
138+
this.getDom(this.__dom)
123139
},
124140
getDom : function(dom){
125141
for(var prop in dom){
126-
this[prop] = dog.$(dom[prop]);
142+
this[prop] = dog.$(dom[prop])
127143
}
128144
},
129145
render : function(){
146+
var dom = null
130147

148+
if(!(dom = dog.$('#panel'))){
149+
this.createPanel()
150+
} else {
151+
dog.show(dom)
152+
}
153+
},
154+
createPanel : function(){
155+
this.createBody()
156+
this.setDom()
157+
this.createLump()
158+
},
159+
createBody : function(){
160+
var div = document.createElement('div'),
161+
pos = dog.position(this.input)
162+
163+
div.id = 'panel'
164+
div.innerHTML = this.tpl[0]
165+
div.style.top = pos.top + 32 + 'px'
166+
div.style.left = pos.left + 'px'
167+
div.children[0].style.display = 'block'
168+
this.container.appendChild(div)
169+
this.calendar = div
170+
},
171+
createLump : function(){
172+
var data = this.getColorsData(),
173+
tplHtml = this.tplList,
174+
__list = this.__list
175+
176+
console.log(data);
177+
__list.innerHTML = dog.tpl(tplHtml.innerHTML, data)
178+
},
179+
getColorsData : function(){
180+
var arr = ['0', '3', '6', '9', 'c', 'f'],
181+
data = []
182+
183+
for (var i = 0; i < arr.length; i++) {
184+
data.push(this.createColors(arr[i], arr))
185+
}
186+
return data
187+
},
188+
createColors : function(one, arr){
189+
var colors = []
190+
191+
for (var i = 0; i < 6; i++) {
192+
for(var j = 0; j < 6; j++) {
193+
colors.push(one + arr[j] + arr[i])
194+
}
195+
}
196+
return colors
131197
}
132198
}
133199

134200
var defaults = {
135201
dom : {
136-
container : '#calendar',
137-
input : '#input'
138-
},
139-
zh : {
140-
days : ['日','一','二','三','四','五','六'],
141-
months : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
142-
monthsShort : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一','十二'],
143-
today : '今天',
144-
clear : '清空'
202+
container : '#container',
203+
input : '#input',
204+
tplList : '#tpl-list'
145205
},
146206
tpl :
147207
[
148-
'<div class="datetimepicker datetimepicker-dropdown-bottom-right dropdown-menu">' +
149-
'<div class="datetimepicker-days">' +
150-
'<table class="table-condensed">' +
151-
'<thead>' +
152-
'<tr>' +
153-
'<th class="prev"><i class="icon-arrow-left"></i></th>' +
154-
'<th colspan="5" class="switch"></th>' +
155-
'<th class="next"><i class="icon-arrow-right"></i></th>' +
156-
'</tr>' +
157-
'</thead>' +
158-
'<tbody></tbody>' +
159-
'<tfoot class="none">' +
160-
'<tr><th colspan="7" class="today"></th></tr>' +
161-
'<tr><th colspan="7" class="clear"></th></tr>' +
162-
'</tfoot>' +
163-
'</table>' +
164-
'</div>' +
165-
'</div>',
166-
'1'
208+
'<div class="color-panle">' +
209+
' <div class="color-read">' +
210+
' <span class="color-val"></span><span class="color-show"></span>' +
211+
' </div>' +
212+
' <div class="color-list">' +
213+
' </div>' +
214+
'</div>'
167215
]
168216

169217
}
170218
document.getElementById('input').onclick = function(e){
171-
new Calendar(defaults);
172-
e.stopPropagation();
219+
new Palette(defaults)
173220
}
174221
}());
222+
223+
var data = [
224+
['000','111','022'],
225+
['900','911','922'],
226+
['c00','c11','c22'],
227+
]
175228
</script>
176229
</body>
177230
</html>

0 commit comments

Comments
 (0)