By
smike
Понимаю что во времена Angular, React и прочих фреймоврков может быть не очень актуально, но все же решил опубликовать свою простенькую библиотеку для огранизации плагинов старого доброго jQuery. Библиотека решает следующие задачи:
Организация кода плагина в виде псевдо-класса
Наследование плагинов
Передача параметров в плагин
Подключение плагинов к странице
Ajax-перзагрузка плагинов
Подписка на события
Если кому интересно, прошу сюда: https://bitbucket.org/grifix/envo
Примеры использования тут: https://bitbucket.org/grifix/envo/sr...les/?at=master
Пример плагина:
(function ($) {
var parent = envo.Plugin; // Плагин от которого наследуется данный плагин
var prototype = envo.makePluginPrototype(
'demo.PluginA', // Название псевдо-класса плагина (используется при наследовнии)
'demo_pluginA', // Имя плагина (используется для подключиня плагина к DOM-элементам)
parent,
{
message: 'Hello world!' //Конфигурация плагина по умолчанию
}
);
// Функция которая подключается к плагину в момент наложения его на DOM елемент
prototype.init = function () {
var that = this;
that.elButton = that.find('button');
that.elButton.click(function () {
that.showMessage();
});
parent.prototype.init.call(that);
};
// Метод псевдо-класса плагина
prototype.showMessage = function () {
var that = this;
alert(that.cfg.message);
return that.el();
};
})(jQuery);
Плагин кототрый наследует предыдущий плагин:
(function ($) {
var parent = demo.PluginA;
var prototype = envo.makePluginPrototype(
'demo.PluginB',
'demo_pluginB',
parent
);
prototype.showMessage = function () {
var that = this;
parent.prototype.showMessage.call(that);
confirm("Are you sure!");
return that.el();
};
})(jQuery);
Question
morohon
Здравствуйте. Есть проблемы с наследованием. Не могу понять, что работает не так. Подскажите пожалуйста, если не затруднит.
код представлен здесь: http://www.morohon.pusku.com/panel/ (там размеры изображения скачут)
css
body .main { width:100%; height:100%; } .main div.rotator{ float:left; max-width: 60%; max-height: 80%; } div.rotator ul{ position: relative; list-style: none; padding: 0px; max-width: inherit; max-height: inherit; } div.rotator ul li { position: absolute; margin: 0 auto; list-style: none; max-width: inherit; max-width: inherit; } div.rotator ul li img { max-width: inherit; max-width: inherit; } div.rotator ul li.show { max-width: inherit; max-height: inherit; z-index:500; } div.rotator ul li.show img { max-width: inherit; max-height: inherit; } .main div.right { float:right; max-width: 40%; max-height:80%; } div.right .logo img { max-width: 35%; max-height: 30%; margin: 0 auto; } div.right .clock{ max-width:35%; max-height:auto; margin: 0 auto; } .main div.marquee { width: 100%; max-height: 20%; } .main div.marquee .marq { position: absolute; bottom: 0; right: 0; left: 0; } .main div.marquee .marq .text { color: blue; font-size:95px; }html
<body> <?php $count=count(glob($path.'/*.jpg')); ?> <div class="main"> <div class="rotator"> <ul> <li class="show"><img src="<?php echo $path.'/1'.$type; ?>"/></li> <?php for ($i=2;$i<=$count;$i++){?> <li><img src="<?php echo $path.'/'.$i.$type; ?>"/></li> <?php }?> </ul> </div> <div class="right"> <div class="logo"> <img src="<?php echo 'config_images/'.$row['logo']; ?>" class="main"> </div> <div class="clock"> <?php include "clock/index.html"; ?> </div> </div> <div class="marquee"> <marquee direction="left" loop="-1" behavior="scroll" scrolldelay="1" scrollamount="10" class="marq"> <span class="text"><?php echo $row['marquee'];?></span> </marquee> </div> </div></body>Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.