did not find any suitable pluginI want to say the following.
(function ($) { var methods = { init: function (options) { settings = $.extend({}, options); return this.each(function () { }); $.fn.spoiler = function (method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error(' ' + method + ' jQuery.spoiler'); } }; })(jQuery);
return this.each(function () { });
. It indicates that the plugin must be initialized for each block that corresponds to the selector specified during initialization of the plugin. init: function (options) { settings = $.extend({ // , . "" text: '', // , . collapsed: true, // . , / animationTimeout: 1000 }, options);
, . , , ... , . , .
return this.each(function () {}); :
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
, . , , ... , . , .
return this.each(function () {});
:
// var spoilerControl = '<div class="spoilerControl">' + settings['text'] + '</div>'; // data $(this).data('hasSpoiler',true); // $(this).prepend(spoilerControl); // $(this).data('defaultHeight', $(this).height()); // \ $(this).data('collapsed',settings['collapsed']); // $(this).addClass('spoilerContainer'); var Control = $(this).find('.spoilerControl'); $(this).css('height', $(Control).css('height')); // , true if ($(this).data('collapsed') == true) { // $(this).css('height', $(Control).css('height')); // $(Control).addClass('plus'); } else { // $(this).css('height',$(this).data('defaultHeight')); // $(this).addClass('minus'); } // $(Control).click(function () { var spoiler = $(this).parent(); var animation; // \ if($(spoiler).data('currentAnimation')!=undefined){ // , $(spoiler).data('currentAnimation').stop(); } // if ($(spoiler).data('collapsed') != true) { // $(this).removeClass('minus'); $(this).addClass('plus'); // animation animation=$(spoiler).animate({ // height: $(this).css('height') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',true); } else { // $(this).removeClass('plus'); $(this).addClass('minus'); // animation animation=$(spoiler).animate({ // height: $(spoiler).data('defaultHeight') }, // settings['animationTimeout'], // animation, , function(){ $(spoiler).data('currentAnimation',undefined) }); // "" $(spoiler).data('collapsed',false); } // data , $(spoiler).data('currentAnimation',animation); });
, , . , , . , , .
. .
, - . , .. . var spoilerControl = '' + settings['text'] + '';
// if($(this).data('hasSpoiler')!=undefined) return false;
. , . "", .
, . ? , " ".
:
init: function (options) { // .... }, destroy: function(){ // , return this.each(function () { // data $(this).removeData(); // var control = $(this).find('.spoilerControl'); var defaultHeight = $(control).data('defaultHeight'); $(this).removeClass('spoilerContainer'); // $(control).remove(); // $(this).css('height', defaultHeight); }); }
, ( ).
. , jQuery UI . , , +10 +5 .
, - .
github
data, .
Source: https://habr.com/ru/post/272353/
All Articles