3 Star 0 Fork 0

Gitee 极速下载/jStyler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/maheshwaghmare/jStyler
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jStyler.js 3.64 KB
一键复制 编辑 原始数据 按行查看 历史
Mahesh Waghmare 提交于 2015-12-01 00:04 . Created jStyler.js
/* ========================================================================
* jStyler.js v1.0
* https://jStyler
* http://jStyler
*
* ========================================================================
* Copyright 2015 Mahesh Waghmare
* ======================================================================== */
;(function ($, window, document, undefined) {
var pluginName = "jStyler";
var defaults = {
css_normal: '',
css_hover: '',
selector: '',
// onShown: function() {},
};
function jStyler(element, options) {
this.element = element;
this.$element = $(element);
this.options = $.extend({}, defaults, options, this.$element.data());
this._defaults = defaults;
this._name = pluginName;
this.init();
}
jStyler.prototype = {
init: function () {
// DEFAULT
// var css = {
// normal: {
// bg: "green",
// c: "red",
// },
// hover: {
// bg: "red",
// c: "green",
// }
// };
// console.log( JSON.stringify(css) );
var css = this.options.jstyler;
var normal = this._defaults.css_normal;
var hover = this._defaults.css_hover;
// Loop `normal` & `hover` key css
$.each( css , function( pk , pv ){
// console.log( 'parent_key : ' + JSON.stringify( pk ) );
// console.log( 'parent_value : ' + JSON.stringify( pv ) );
$.each( pv , function( ck , cv ){
// console.log( 'child__key : ' + JSON.stringify( ck ) );
// console.log( 'child__value : ' + JSON.stringify( cv ) );
switch( pk ) {
case 'normal': normal = ck + ':' + cv + ';'; // normal += this.get(ck, cv); // Generate & assign css to variable
break;
case 'hover': hover = ck + ':' + cv + ';'; // hover += this.get(ck, cv); // Generate & assign css to variable
break;
}
});
});
console.log( normal );
console.log( hover );
},
// get: function(ck, cv) {
// // switch(ck) {
// // // For these properties - Not has prefix 'px', 'em' etc
// // case 'c':
// // case 'bg':
// // case 'color':
// // case 'background': c = ck + ':' + cv + ';';
// // break;
// // case 'font-size': c = ck + ':' + cv + ';';
// // break;
// // }
// console.log( ck + ':' + cv + ';' );
// // return ck + ':' + cv + ';';
// },
show: function() {
console.log('okay');
},
};
$.fn[pluginName] = function (options, args) {
//console.log($.data(this, "plugin_" + pluginName));
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new jStyler(this, options));
}
});
};
$(document).ready(function() {
// Initially call - `jStyler`
$("[data-jstyler]").jStyler();
// var css = $('[data-jstyler]').attr('data-jstyler');
// // var css = $('[data-jstyler]').attr('data-t');
// console.log( JSON.stringify(css) );
});
})(jQuery, window, document);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/jStyler.git
git@gitee.com:mirrors/jStyler.git
mirrors
jStyler
jStyler
master

搜索帮助