1/* 2params { 3 tg-class-name: 'toogled' 4 tg-target-id: 'targetId' 5 tg-off-body: true 6 tg-off-add: true 7 tg-off-label: 'ÐакÑÑÑÑ' 8 tg-flag-label: 'ÐакÑÑÑÑ' 9} 10*/ 11;(function($) { 12 function Toogler(node, params) { 13 this.node = node; 14 this.params = $.sigma.getOpts(node, params, 'tg'); 15 this.closeBtn = null; 16 this.targetObj = null; 17 this.bFlag = this.params.flag; 18 this.loader = null; 19 20 this._bodyClose = null; 21 this._t_clicked = false; 22 } 23 Toogler.prototype.init = function() { 24 var p = this.params, item, that = this; 25 26 if(!p.targetId) return; 27 this.targetObj = document.getElementById(p.targetId); 28 if(!this.targetObj) return; 29 30 if(this.bFlag) this.turnOn(); 31 32 this.node.onclick = function(e) { 33 that.toogle(); 34 (e || event).stopPropagation(); 35 return false; 36 } 37 if(p.offAdd) { 38 item = document.createElement('i'); 39 item.className = 'toogled-close'; 40 item.innerHTML = p.offLabel; 41 this.closeBtn = this.targetObj.appendChild(item); 42 this.closeBtn.onclick = function() { 43 that.turnOff(); 44 } 45 } 46 47 if(p.offBody) { 48 this._bodyClose = function(e) { 49 if(this == that.targetObj) { 50 that._t_clicked = true; 51 } 52 else { 53 if(!that._t_clicked) 54 that.turnOff(); 55 that._t_clicked = false; 56 } 57 }; 58 } 59 } 60 Toogler.prototype.checkLoad = function() { 61 var url, pos; 62 if(this.loader !== null) return; 63 this.loader = false;
64 if(this.node.tagName.toLowerCase() == 'a') { 65 url = this.node.getAttribute('href'); 66 pos = url.indexOf('#'); 67 if(pos > 0) url = url.substr(0, pos); 68 else if(pos == 0) url = ''; 69 70 if(url.length > 0) { 71 this.loader = this.targetObj.appendChild( 72 document.createElement('div')); 73 this.loader.className = 'ajax-area'; 74 this.loader.setAttribute('data-ap-page-src', url); 75 this.loader.setAttribute('data-ap-find-link', 'a.ajax-link'); 76 this.loader.setAttribute('data-ap-find-popup', ''); 77 78 $(document).trigger('bx.ready', this.targetObj); 79 } 80 } 81 } 82 Toogler.prototype.turnOn = function() { 83 var p = this.params, that = this; 84 if(this.bFlag) return; 85 this.node.className += ' '+p.className; 86 this.targetObj.className += ' '+p.className; 87 88 this.bFlag = true; 89 this.checkLoad(); 90 if(this._bodyClose) { 91 $(this.targetObj).bind('click', this._bodyClose); 92 $(document.body).bind('click', this._bodyClose); 93 } 94 } 95 Toogler.prototype.turnOff = function() { 96 var p = this.params, that = this; 97 if(!this.bFlag) return; 98 this.node.className = this.node.className.replace(' '+p.className, ''); 99 this.targetObj.className = this.targetObj.className.replace(' '+p.className, ''); 100 101 this.bFlag = false; 102 if(this._bodyClose) { 103 $(this.targetObj).bind('click', this._bodyClose); 104 $(document.body).unbind('click', this._bodyClose); 105 } 106 } 107 Toogler.prototype.toogle = function() { 108 this.bFlag ? this.turnOff() : this.turnOn(); 109 } 110 111 $.fn.Toogler = function(params) 112 { 113 var params = $.extend({}, { 114 className: 'toogled', // Ð´Ð»Ñ ÐºÐ¾Ð½ÑейнеÑов Ñипа DIV - URL Ð´Ð»Ñ Ð·Ð°Ð³ÑÑзки 115 targetId: '', // задеÑжка пеÑед загÑÑзкой 116 offBody: true, 117 offAdd: true, 118 offLabel: 'ÐакÑÑÑÑ', 119 flag: false 120 }, params); 121 122 return this.each(function() { 123 var toogler = new Toogler(this, params); 124 toogler.init(); 125 $(this).bind('toogle', function(e) { 126 toogler.toogle(); 127 }); 128 $(this).bind('off', function(e) { 129 toogler.turnOff(); 130 }); 131 $(this).bind('on', function(e) { 132 toogler.turnOn(); 133 }); 134 }); 135 } 136 137 $(document).ready(function() { 138 $('.toogles').Toogler(); 139 }); 140})(jQuery); 141 142
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.