Skip to content
This repository was archived by the owner on Nov 14, 2018. It is now read-only.

Commit 6d56a9b

Browse files
lossirlossir
lossir
authored and
lossir
committed
Рефакторинг
1 parent 22bf39e commit 6d56a9b

File tree

4 files changed

+64
-38
lines changed

4 files changed

+64
-38
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
jL/old/*
2-
.idea
2+
.idea
3+
jquery-1.11.2.js
4+
es5-shim.map
5+
html5forIE.min.js

jL.js

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
//Time: 10:51
1515
//TODO: Написать "перехватчик" ajax запросов, для отслеживания появления новых элементов
1616

17+
//Date: 20.08.2015
18+
//Time: 13:38
19+
//TODO: Необходимо подробно просмотреть реализацию мелких, но важных функций для ie8\9
1720

1821
(function ($) {
1922
"use strict";
@@ -56,6 +59,14 @@
5659
expansionDefineProperty(Array.prototype, 'diff', function(a) {
5760
return this.filter(function(i) {return a.indexOf(i) < 0;});
5861
});
62+
expansionDefineProperty(window.Element.prototype, 'getElementsByClassName', function (className) {
63+
return Array.prototype.filter.call(this.getElementsByTagName("*"), function (item) {
64+
return !~item.className.split(" ").indexOf(className);
65+
});
66+
});
67+
expansionDefineProperty(window.Element.prototype, 'addEventListener', function () {
68+
//console.log(this,arguments);
69+
});
5970
expansionDefineProperty(Array.prototype, 'forEach', function (func) {
6071
func = func || false;
6172
var key,

utilities/class-action/example.html

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
<!doctype html>
2-
<html lang="ru">
2+
<!--[if lt IE 7]><html class="ie ie6" lang="ru"><![endif]-->
3+
<!--[if IE 7]><html class="ie ie7" lang="ru"><![endif]-->
4+
<!--[if IE 8]><html class="ie ie8" lang="ru"><![endif]-->
5+
<!--[if IE 9]><html class="ie ie9" lang="ru"><![endif]-->
6+
<!--[if (gt IE 9)|!(IE)]><!--><html lang="ru"><!--<![endif]-->
37
<head>
8+
9+
410
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">
511
<meta http-equiv="content-language" content="ru"/>
612
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
713

814
<link rel="stylesheet" href="/cutback.css"/>
915
<link rel="stylesheet" href="style.css"/>
1016

11-
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
17+
<!--[if lt IE 9]><script src="/html5forIE.min.js"></script><![endif]-->
18+
19+
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
1220
<!--<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>-->
1321
<!--<script src="/js/jquery-1.11.2.min.js"></script>-->
1422
<script src="/jL.js"></script>
@@ -27,6 +35,9 @@
2735
.selected {
2836
box-shadow: inset 0 0 0 1px red;
2937
}
38+
.ie8 .selected {
39+
border: solid 1px red;
40+
}
3041

3142
.disabled {
3243
opacity: 0.4;
@@ -80,7 +91,7 @@
8091
<li class="cu-p">2</li>
8192
<li class="cu-p">3</li>
8293
<li class="cu-p">4</li>
83-
<li class="cu-p">5</li>
94+
<li class="cu-p selected">5</li>
8495
<li class="cu-p">6</li>
8596
<li class="cu-p">7</li>
8697
<li class="cu-p">8</li>

utilities/class-action/jL.utility.class-action.js

+35-34
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,39 @@
163163
}
164164
},
165165
{
166-
'className' : 'placeholder',
166+
'className' : '.ie9[placeholder]',
167167
/**
168168
*/
169169
'action': function () {
170170
var elems = $(this);
171-
jL.IEBind.add('8,9', function(){
172-
elems.each(function () {
173-
var $this = $(this),
174-
placeholder = $this.attr('placeholder'),
175-
tag = $this.prop('tagName'),
176-
color = $this.prop('color'),
177-
method = (tag === 'INPUT') ? 'val'
178-
: 'text',
179-
placeholderShow = function () {
180-
if($this[method]() === placeholder){
181-
$this.css('color', color);
182-
$this[method]('');
183-
}
184-
},
185-
placeholderHide = function () {
186-
var value = $this[method]();
187-
$this[method](value === placeholder || value === '' ? function () {
188-
$this.css('color', '#aaaaaa');
189-
return placeholder;
190-
}()
191-
: value);
192-
};
193-
$this.on( "focus", placeholderShow);
194-
$this.on( "blur", placeholderHide);
195-
placeholderHide();
171+
//jL.IEBind.add('8,9', function(){
172+
elems.each(function () {
173+
var $this = $(this),
174+
placeholder = $this.attr('placeholder'),
175+
tag = $this.prop('tagName'),
176+
color = $this.prop('color'),
177+
method = (tag === 'INPUT') ? 'val'
178+
: 'text',
179+
placeholderShow = function () {
180+
if($this[method]() === placeholder){
181+
$this.css('color', color);
182+
$this[method]('');
183+
}
184+
},
185+
placeholderHide = function () {
186+
var value = $this[method]();
187+
$this[method](value === placeholder || value === '' ? function () {
188+
$this.css('color', '#aaaaaa');
189+
return placeholder;
190+
}()
191+
: value);
192+
};
193+
$this.on( "focus", placeholderShow);
194+
$this.on( "blur", placeholderHide);
195+
placeholderHide();
196196
// $this[method](placeholder);
197-
});
198197
});
198+
//});
199199
}
200200
},
201201
{
@@ -229,7 +229,7 @@
229229
}
230230
},
231231
{
232-
'className' : 'select-css',
232+
'className' : '.ca-select-css',
233233
/**
234234
* <pre>
235235
* Создание стилизованного тега select
@@ -322,20 +322,21 @@
322322
}
323323
},
324324
{
325-
'className' : 'switch,switch-block',
325+
'className' : '.ca-switch, .ca-switch-block',
326326
/**
327327
* Переключение класса "selected" между набором элементов
328328
*/
329329
'action': function () {
330-
var $this = $(this),
330+
var self = this,
331+
$this = $(this),
331332
switchClass = 'selected',
332333
items = this.children,
333334
$items = $(items);
334335
// элементы могут переключать класс "selected" внутри своего набора
335336
if($this.hasClass('ca-switch')) {
336-
$this.on('click', '>*', function (index) {
337+
$(document).on("click", ">*", function (e) {
337338
$items.removeClass(switchClass);
338-
this.className += " "+switchClass;
339+
event.srcElement.className += " "+switchClass;
339340
});
340341
}
341342
// или в другом наборе элементов
@@ -357,7 +358,7 @@
357358
}
358359
},
359360
{
360-
'className' : 'popup-image',
361+
'className' : '.ca-popup-image',
361362
'action': function () {
362363

363364
}
@@ -366,7 +367,7 @@
366367

367368
$(function(){
368369
actions.forEach(function(item){
369-
$(getSelector(item.className,',')).each(item.action);
370+
$(item.className).each(item.action);
370371
});
371372
});
372373

0 commit comments

Comments
 (0)