-
Notifications
You must be signed in to change notification settings - Fork 0
/
mishanga.js
3372 lines (2647 loc) · 93.5 KB
/
mishanga.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ../../bem-bl/blocks-common/i-jquery/__inherit/i-jquery__inherit.js: begin */ /**/
/**
* Inheritance plugin
*
* Copyright (c) 2010 Filatov Dmitry ([email protected])
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @version 1.3.5
*/
(function($) {
var hasIntrospection = (function(){_}).toString().indexOf('_') > -1,
emptyBase = function() {},
objCreate = Object.create || function(ptp) {
var inheritance = function() {};
inheritance.prototype = ptp;
return new inheritance();
},
needCheckProps = true,
testPropObj = { toString : '' };
for(var i in testPropObj) { // fucking ie hasn't toString, valueOf in for
testPropObj.hasOwnProperty(i) && (needCheckProps = false);
}
var specProps = needCheckProps? ['toString', 'valueOf'] : null;
function override(base, result, add) {
var hasSpecProps = false;
if(needCheckProps) {
var addList = [];
$.each(specProps, function() {
add.hasOwnProperty(this) && (hasSpecProps = true) && addList.push({
name : this,
val : add[this]
});
});
if(hasSpecProps) {
$.each(add, function(name) {
addList.push({
name : name,
val : this
});
});
add = addList;
}
}
$.each(add, function(name, prop) {
if(hasSpecProps) {
name = prop.name;
prop = prop.val;
}
if($.isFunction(prop) &&
(!hasIntrospection || prop.toString().indexOf('.__base') > -1)) {
var baseMethod = base[name] || function() {};
result[name] = function() {
var baseSaved = this.__base;
this.__base = baseMethod;
var result = prop.apply(this, arguments);
this.__base = baseSaved;
return result;
};
}
else {
result[name] = prop;
}
});
}
$.inherit = function() {
var args = arguments,
hasBase = $.isFunction(args[0]),
base = hasBase? args[0] : emptyBase,
props = args[hasBase? 1 : 0] || {},
staticProps = args[hasBase? 2 : 1],
result = props.__constructor || (hasBase && base.prototype.__constructor)?
function() {
return this.__constructor.apply(this, arguments);
} : function() {};
if(!hasBase) {
result.prototype = props;
result.prototype.__self = result.prototype.constructor = result;
return $.extend(result, staticProps);
}
$.extend(result, base);
var basePtp = base.prototype,
resultPtp = result.prototype = objCreate(basePtp);
resultPtp.__self = resultPtp.constructor = result;
override(basePtp, resultPtp, props);
staticProps && override(base, result, staticProps);
return result;
};
$.inheritSelf = function(base, props, staticProps) {
var basePtp = base.prototype;
override(basePtp, basePtp, props);
staticProps && override(base, base, staticProps);
return base;
};
})(jQuery);;
/* ../../bem-bl/blocks-common/i-jquery/__inherit/i-jquery__inherit.js: end */ /**/
/* ../../bem-bl/blocks-common/i-jquery/__identify/i-jquery__identify.js: begin */ /**/
/**
* Identify plugin
*
* @version 1.0.0
*/
(function($) {
var counter = 0,
expando = '__' + (+new Date),
get = function() {
return 'uniq' + ++counter;
};
/**
* Makes unique ID
* @param {Object} [obj] Object that needs to be identified
* @param {Boolean} [onlyGet=false] Return a unique value only if it had already been assigned before
* @returns {String} ID
*/
$.identify = function(obj, onlyGet) {
if(!obj) return get();
var key = 'uniqueID' in obj? 'uniqueID' : expando; // Use when possible. native uniqueID for elements in IE
return onlyGet || key in obj?
obj[key] :
obj[key] = get();
};
})(jQuery);;
/* ../../bem-bl/blocks-common/i-jquery/__identify/i-jquery__identify.js: end */ /**/
/* ../../bem-bl/blocks-common/i-jquery/__is-empty-object/i-jquery__is-empty-object.js: begin */ /**/
(function($) {
$.isEmptyObject || ($.isEmptyObject = function(obj) {
for(var i in obj) return false;
return true;
});
})(jQuery);
;
/* ../../bem-bl/blocks-common/i-jquery/__is-empty-object/i-jquery__is-empty-object.js: end */ /**/
/* ../../bem-bl/blocks-common/i-jquery/__debounce/i-jquery__debounce.js: begin */ /**/
/**
* Debounce and throttle function's decorator plugin 1.0.6
*
* Copyright (c) 2009 Filatov Dmitry ([email protected])
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($) {
$.extend({
debounce : function(fn, timeout, invokeAsap, ctx) {
if(arguments.length == 3 && typeof invokeAsap != 'boolean') {
ctx = invokeAsap;
invokeAsap = false;
}
var timer;
return function() {
var args = arguments;
ctx = ctx || this;
invokeAsap && !timer && fn.apply(ctx, args);
clearTimeout(timer);
timer = setTimeout(function() {
invokeAsap || fn.apply(ctx, args);
timer = null;
}, timeout);
};
},
throttle : function(fn, timeout, ctx) {
var timer, args, needInvoke;
return function() {
args = arguments;
needInvoke = true;
ctx = ctx || this;
timer || (function() {
if(needInvoke) {
fn.apply(ctx, args);
needInvoke = false;
timer = setTimeout(arguments.callee, timeout);
}
else {
timer = null;
}
})();
};
}
});
})(jQuery);;
/* ../../bem-bl/blocks-common/i-jquery/__debounce/i-jquery__debounce.js: end */ /**/
/* ../../bem-bl/blocks-common/i-jquery/__observable/i-jquery__observable.js: begin */ /**/
/**
* Observable plugin
*
* Copyright (c) 2010 Filatov Dmitry ([email protected])
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @version 1.0.0
* @requires $.identify
* @requires $.inherit
*/
(function($) {
var storageExpando = '__' + +new Date + 'storage',
getFnId = function(fn, ctx) {
return $.identify(fn) + (ctx? $.identify(ctx) : '');
},
Observable = /** @lends $.observable.prototype */{
/**
* Builds full event name
* @protected
* @param {String} e Event type
* @returns {String}
*/
buildEventName : function(e) {
return e;
},
/**
* Adding event handler
* @param {String} e Event type
* @param {Object} [data] Additional data that the handler gets as e.data
* @param {Function} fn Handler
* @param {Object} [ctx] Handler context
* @returns {$.observable}
*/
on : function(e, data, fn, ctx, _special) {
if(typeof e == 'string') {
if($.isFunction(data)) {
ctx = fn;
fn = data;
data = undefined;
}
var id = getFnId(fn, ctx),
storage = this[storageExpando] || (this[storageExpando] = {}),
eList = e.split(' '),
i = 0,
eStorage;
while(e = eList[i++]) {
e = this.buildEventName(e);
eStorage = storage[e] || (storage[e] = { ids : {}, list : {} });
if(!(id in eStorage.ids)) {
var list = eStorage.list,
item = { fn : fn, data : data, ctx : ctx, special : _special };
if(list.last) {
list.last.next = item;
item.prev = list.last;
} else {
list.first = item;
}
eStorage.ids[id] = list.last = item;
}
}
} else {
var _this = this;
$.each(e, function(e, fn) {
_this.on(e, fn, data, _special);
});
}
return this;
},
onFirst : function(e, data, fn, ctx) {
return this.on(e, data, fn, ctx, { one : true });
},
/**
* Removing event handler(s)
* @param {String} [e] Event type
* @param {Function} [fn] Handler
* @param {Object} [ctx] Handler context
* @returns {$.observable}
*/
un : function(e, fn, ctx) {
if(typeof e == 'string' || typeof e == 'undefined') {
var storage = this[storageExpando];
if(storage) {
if(e) { // if event type was passed
var eList = e.split(' '),
i = 0,
eStorage;
while(e = eList[i++]) {
e = this.buildEventName(e);
if(eStorage = storage[e]) {
if(fn) { // if specific handler was passed
var id = getFnId(fn, ctx),
ids = eStorage.ids;
if(id in ids) {
var list = eStorage.list,
item = ids[id],
prev = item.prev,
next = item.next;
if(prev) {
prev.next = next;
}
else if(item === list.first) {
list.first = next;
}
if(next) {
next.prev = prev;
}
else if(item === list.last) {
list.last = prev;
}
delete ids[id];
}
} else {
delete this[storageExpando][e];
}
}
}
} else {
delete this[storageExpando];
}
}
} else {
var _this = this;
$.each(e, function(e, fn) {
_this.un(e, fn, ctx);
});
}
return this;
},
/**
* Fires event handlers
* @param {String|$.Event} e Event
* @param {Object} [data] Additional data
* @returns {$.observable}
*/
trigger : function(e, data) {
var _this = this,
storage = _this[storageExpando],
rawType;
typeof e === 'string'?
e = $.Event(_this.buildEventName(rawType = e)) :
e.type = _this.buildEventName(rawType = e.type);
e.target || (e.target = _this);
if(storage && (storage = storage[e.type])) {
var item = storage.list.first,
ret;
while(item) {
e.data = item.data;
ret = item.fn.call(item.ctx || _this, e, data);
if(typeof ret !== 'undefined') {
e.result = ret;
if(ret === false) {
e.preventDefault();
e.stopPropagation();
}
}
item.special && item.special.one &&
_this.un(rawType, item.fn, item.ctx);
item = item.next;
}
}
return this;
}
};
$.observable = $.inherit(Observable, Observable);
})(jQuery);;
/* ../../bem-bl/blocks-common/i-jquery/__observable/i-jquery__observable.js: end */ /**/
/* ../../bem-bl/blocks-common/i-bem/i-bem.js: begin */ /**/
/** @requires jquery.inherit */
/** @requires jquery.isEmptyObject */
/** @requires jquery.identify */
/** @requires jquery.observable */
(function($, undefined) {
/**
* Storage for deferred functions
* @private
* @type Array
*/
var afterCurrentEventFns = [],
/**
* Storage for block declarations (hash by block name)
* @private
* @type Object
*/
blocks = {},
/**
* Communication channels
* @static
* @private
* @type Object
*/
channels = {};
/**
* Builds the name of the handler method for setting a modifier
* @static
* @private
* @param {String} elemName Element name
* @param {String} modName Modifier name
* @param {String} modVal Modifier value
* @returns {String}
*/
function buildModFnName(elemName, modName, modVal) {
return (elemName? '__elem_' + elemName : '') +
'__mod' +
(modName? '_' + modName : '') +
(modVal? '_' + modVal : '');
}
/**
* Transforms a hash of modifier handlers to methods
* @static
* @private
* @param {Object} modFns
* @param {Object} props
* @param {String} [elemName]
*/
function modFnsToProps(modFns, props, elemName) {
$.isFunction(modFns)?
(props[buildModFnName(elemName, '*', '*')] = modFns) :
$.each(modFns, function(modName, modFn) {
$.isFunction(modFn)?
(props[buildModFnName(elemName, modName, '*')] = modFn) :
$.each(modFn, function(modVal, modFn) {
props[buildModFnName(elemName, modName, modVal)] = modFn;
});
});
}
function buildCheckMod(modName, modVal) {
return modVal?
Array.isArray(modVal)?
function(block) {
var i = 0, len = modVal.length;
while(i < len)
if(block.hasMod(modName, modVal[i++]))
return true;
return false;
} :
function(block) {
return block.hasMod(modName, modVal);
} :
function(block) {
return block.hasMod(modName);
};
}
/** @namespace */
this.BEM = $.inherit($.observable, /** @lends BEM.prototype */ {
/**
* @class Base block for creating BEM blocks
* @constructs
* @private
* @param {Object} mods Block modifiers
* @param {Object} params Block parameters
* @param {Boolean} [initImmediately=true]
*/
__constructor : function(mods, params, initImmediately) {
var _this = this;
/**
* Cache of block modifiers
* @private
* @type Object
*/
_this._modCache = mods || {};
/**
* Current modifiers in the stack
* @private
* @type Object
*/
_this._processingMods = {};
/**
* The block's parameters, taking into account the defaults
* @protected
* @type Object
*/
_this._params = params; // это нужно для правильной сборки параметров у блока из нескольких нод
_this.params = null;
initImmediately !== false?
_this._init() :
_this.afterCurrentEvent(function() {
_this._init();
});
},
/**
* Initializes the block
* @private
*/
_init : function() {
if(!this._initing && !this.hasMod('js', 'inited')) {
this._initing = true;
if(!this.params) {
this.params = $.extend(this.getDefaultParams(), this._params);
delete this._params;
}
this.setMod('js', 'inited');
delete this._initing;
this.hasMod('js', 'inited') && this.trigger('init');
}
return this;
},
/**
* Changes the context of the function being passed
* @protected
* @param {Function} fn
* @param {Object} [ctx=this] Context
* @returns {Function} Function with a modified context
*/
changeThis : function(fn, ctx) {
return fn.bind(ctx || this);
},
/**
* Executes the function in the context of the block, after the "current event"
* @protected
* @param {Function} fn
* @param {Object} [ctx] Context
*/
afterCurrentEvent : function(fn, ctx) {
this.__self.afterCurrentEvent(this.changeThis(fn, ctx));
},
/**
* Executes the block's event handlers and live event handlers
* @protected
* @param {String} e Event name
* @param {Object} [data] Additional information
* @returns {BEM}
*/
trigger : function(e, data) {
this
.__base(e = this.buildEvent(e), data)
.__self.trigger(e, data);
return this;
},
buildEvent : function(e) {
typeof e == 'string' && (e = $.Event(e));
e.block = this;
return e;
},
/**
* Checks whether a block or nested element has a modifier
* @protected
* @param {Object} [elem] Nested element
* @param {String} modName Modifier name
* @param {String} [modVal] Modifier value
* @returns {Boolean}
*/
hasMod : function(elem, modName, modVal) {
var len = arguments.length,
invert = false;
if(len == 1) {
modVal = '';
modName = elem;
elem = undefined;
invert = true;
}
else if(len == 2) {
if(typeof elem == 'string') {
modVal = modName;
modName = elem;
elem = undefined;
}
else {
modVal = '';
invert = true;
}
}
var res = this.getMod(elem, modName) === modVal;
return invert? !res : res;
},
/**
* Returns the value of the modifier of the block/nested element
* @protected
* @param {Object} [elem] Nested element
* @param {String} modName Modifier name
* @returns {String} Modifier value
*/
getMod : function(elem, modName) {
var type = typeof elem;
if(type === 'string' || type === 'undefined') { // elem either omitted or undefined
modName = elem || modName;
var modCache = this._modCache;
return modName in modCache?
modCache[modName] :
modCache[modName] = this._extractModVal(modName);
}
return this._getElemMod(modName, elem);
},
/**
* Returns the value of the modifier of the nested element
* @private
* @param {String} modName Modifier name
* @param {Object} elem Nested element
* @param {Object} [elem] Nested element name
* @returns {String} Modifier value
*/
_getElemMod : function(modName, elem, elemName) {
return this._extractModVal(modName, elem, elemName);
},
/**
* Returns values of modifiers of the block/nested element
* @protected
* @param {Object} [elem] Nested element
* @param {String} [modName1, ..., modNameN] Modifier names
* @returns {Object} Hash of modifier values
*/
getMods : function(elem) {
var hasElem = elem && typeof elem != 'string',
_this = this,
modNames = [].slice.call(arguments, hasElem? 1 : 0),
res = _this._extractMods(modNames, hasElem? elem : undefined);
if(!hasElem) { // caching
modNames.length?
modNames.forEach(function(name) {
_this._modCache[name] = res[name];
}):
_this._modCache = res;
}
return res;
},
/**
* Sets the modifier for a block/nested element
* @protected
* @param {Object} [elem] Nested element
* @param {String} modName Modifier name
* @param {String} modVal Modifier value
* @returns {BEM}
*/
setMod : function(elem, modName, modVal) {
if(typeof modVal == 'undefined') {
modVal = modName;
modName = elem;
elem = undefined;
}
var _this = this;
if(!elem || elem[0]) {
var modId = (elem && elem[0]? $.identify(elem[0]) : '') + '_' + modName;
if(this._processingMods[modId]) return _this;
var elemName,
curModVal = elem?
_this._getElemMod(modName, elem, elemName = _this.__self._extractElemNameFrom(elem)) :
_this.getMod(modName);
if(curModVal === modVal) return _this;
this._processingMods[modId] = true;
var needSetMod = true,
modFnParams = [modName, modVal, curModVal];
elem && modFnParams.unshift(elem);
[['*', '*'], [modName, '*'], [modName, modVal]].forEach(function(mod) {
needSetMod = _this._callModFn(elemName, mod[0], mod[1], modFnParams) !== false && needSetMod;
});
!elem && needSetMod && (_this._modCache[modName] = modVal);
needSetMod && _this._afterSetMod(modName, modVal, curModVal, elem, elemName);
delete this._processingMods[modId];
}
return _this;
},
/**
* Function after successfully changing the modifier of the block/nested element
* @protected
* @param {String} modName Modifier name
* @param {String} modVal Modifier value
* @param {String} oldModVal Old modifier value
* @param {Object} [elem] Nested element
* @param {String} [elemName] Element name
*/
_afterSetMod : function(modName, modVal, oldModVal, elem, elemName) {},
/**
* Sets a modifier for a block/nested element, depending on conditions.
* If the condition parameter is passed: when true, modVal1 is set; when false, modVal2 is set.
* If the condition parameter is not passed: modVal1 is set if modVal2 was set, or vice versa.
* @protected
* @param {Object} [elem] Nested element
* @param {String} modName Modifier name
* @param {String} modVal1 First modifier value
* @param {String} [modVal2] Second modifier value
* @param {Boolean} [condition] Condition
* @returns {BEM}
*/
toggleMod : function(elem, modName, modVal1, modVal2, condition) {
if(typeof elem == 'string') { // if this is a block
condition = modVal2;
modVal2 = modVal1;
modVal1 = modName;
modName = elem;
elem = undefined;
}
if(typeof modVal2 == 'undefined') {
modVal2 = '';
} else if(typeof modVal2 == 'boolean') {
condition = modVal2;
modVal2 = '';
}
var modVal = this.getMod(elem, modName);
(modVal == modVal1 || modVal == modVal2) &&
this.setMod(
elem,
modName,
typeof condition === 'boolean'?
(condition? modVal1 : modVal2) :
this.hasMod(elem, modName, modVal1)? modVal2 : modVal1);
return this;
},
/**
* Removes a modifier from a block/nested element
* @protected
* @param {Object} [elem] Nested element
* @param {String} modName Modifier name
* @returns {BEM}
*/
delMod : function(elem, modName) {
if(!modName) {
modName = elem;
elem = undefined;
}
return this.setMod(elem, modName, '');
},
/**
* Executes handlers for setting modifiers
* @private
* @param {String} elemName Element name
* @param {String} modName Modifier name
* @param {String} modVal Modifier value
* @param {Array} modFnParams Handler parameters
*/
_callModFn : function(elemName, modName, modVal, modFnParams) {
var modFnName = buildModFnName(elemName, modName, modVal);
return this[modFnName]?
this[modFnName].apply(this, modFnParams) :
undefined;
},
/**
* Retrieves the value of the modifier
* @private
* @param {String} modName Modifier name
* @param {Object} [elem] Element
* @returns {String} Modifier value
*/
_extractModVal : function(modName, elem) {
return '';
},
/**
* Retrieves name/value for a list of modifiers
* @private
* @param {Array} modNames Names of modifiers
* @param {Object} [elem] Element
* @returns {Object} Hash of modifier values by name
*/
_extractMods : function(modNames, elem) {
return {};
},
/**
* Returns a named communication channel
* @param {String} [id='default'] Channel ID
* @param {Boolean} [drop=false] Destroy the channel
* @returns {$.observable|undefined} Communication channel
*/
channel : function(id, drop) {
return this.__self.channel(id, drop);
},
/**
* Returns a block's default parameters
* @returns {Object}
*/
getDefaultParams : function() {
return {};
},
/**
* Helper for cleaning up block properties
* @param {Object} [obj=this]
*/
del : function(obj) {
var args = [].slice.call(arguments);
typeof obj == 'string' && args.unshift(this);
this.__self.del.apply(this.__self, args);
return this;
},
/**
* Deletes a block
*/
destruct : function() {}
}, /** @lends BEM */{
_name : 'i-bem',
/**
* Storage for block declarations (hash by block name)
* @static
* @protected
* @type Object
*/
blocks : blocks,
/**
* Declares blocks and creates a block class
* @static
* @protected
* @param {String|Object} decl Block name (simple syntax) or description
* @param {String} decl.block|decl.name Block name
* @param {String} [decl.baseBlock] Name of the parent block
* @param {String} [decl.modName] Modifier name
* @param {String} [decl.modVal] Modifier value
* @param {Object} [props] Methods
* @param {Object} [staticProps] Static methods
*/
decl : function(decl, props, staticProps) {
if(typeof decl == 'string')
decl = { block : decl };
else if(decl.name) {
decl.block = decl.name;
}
if(decl.baseBlock && !blocks[decl.baseBlock])
throw('baseBlock "' + decl.baseBlock + '" for "' + decl.block + '" is undefined');
props || (props = {});
if(props.onSetMod) {
modFnsToProps(props.onSetMod, props);