반응형
반응형

The Holy Grail jQuery Plugin of CSS Design

 

http://www.codeproject.com/Articles/629019/The-Holy-Grail-jQuery-Plugin-of-CSS-Design

 

 

 

The joy of creating jQuery Plugin resides in the fact that you can wrap a big deal of jQuery code that otherwise could end up spread all over your codebase, and by establishing a jQuery Plugin, you can confine a coherent set of functionalities in a self-contained component, and then work on this component in order to make it useful for a very wide community of web developers.

In Holy Grail plogin code, we start by creating a immediately-invoked function expression (IIFE) in JavaScript code. The IIFE is a design pattern that provides the self-containment of private functions variables and functions within the plugin scope, thus avoiding the pollution of JavaScript's Global Environment. JavaScript developers will easily recognize the IIFE pattern by the following code:

 

            (function(){
              /* code */ 
            }());
        

In the above code, the outermost pair of parentheses wrap the function in an expression and immediately forces its evaluation. The pair of parentheses in the last line of code invokes the function immediately.

Notice that, within the jQuery plugin development, it's important to pass the jQuery reference as a parameter in our IIFE expression, so that the dollar sign ($) can be used safely within the scope of the plugin, without the risk of external libraries overriding the dollar sign:

 

            (function($){
              /* Our Holy Grail jQuery Plugin code goes here. Notice the $ sign will never have a meaning other than the jQuery object. */ 
            }(jQuery));
        

Next, we create the function that will hold and execute the whole of our Holy Grail plugin functionality. Notice the options parameter, which will contain all the initialization settings needed to configure the bar chart according to the Holy Grail plugin requirements:

 

            (function($){
              $.fn.holygrail = function (options) {
                    //as expected, our holy grail plugin code falls here.
                }
            }(jQuery));
        

Inside the plugin function, the context is given by the this JavaScript keyword. Most often than not, developers will be tempted to reference the context by enclosing it using the dollar sign (i.e. jQuery) function: "$(this)", instead of just this. This is a common mistake, since the this keyword already refers to the jQuery object and not the DOM element inside which the bar chart is being created:

 

            (function($){
              $.fn.barChart = function (options) {
                    var self = this;
                }
            }(jQuery));
        

In the above JavaScript code, we are storing the value of the this object in the self reference. This is needed specifically inside functions, where the this keyword behaves as the context for the function itself, instead of the context for the outermost plugin function. Thus, the self will be used as the context for the bar chart plugin instead.

The plugin code starts by defining a series of settings that will become the default values for the most common configurations. This will provide our plugin users with convenient standard values that can be either configured (allowing a flexible charting component) or ignored (so that the plugin user can provide the smallest set of startup configuration).

As the plugin component gets more sophisticated, it's generally a good idea to provide a more complete and comprehensive set of default settings, in order to give users a powerful, flexible and unobtrusive plugin.

 

            $.fn.holygrail = function (options) {

                var self = this;

                // Create some defaults, extending them with any options that were provided
                var settings = $.extend({
                    headerContent: options.headerContent,
                    centerContent: options.centerContent,
                    leftContent: options.leftContent,
                    rightContent: options.rightContent,
                    footerContent: options.footerContent
                }, options);

        

The above code snippet shows the plugin settings: there is a different plugin configuration for each of the page's sections: headerContent, centerContent, leftContent, rightContent and footerContent:

 

		=========================
		|         header        |
		=========================
		|      |        |       |
		| left | center | right |
		|      |        |       |
		=========================
		|         footer        |
		=========================
		

The plugin code itself is all about gathering the content elements and rearranging them in a way that the resulting rendering complies with the above layout:

 

			/// <reference path="jquery-1.9.1.min.js">
			(function ($) {

				var HolyGrail = {};

				var raster;

				$.fn.holygrail = function (options) {

					var self = this;

					// Create some defaults, extending them with any options that were provided
					var settings = $.extend({
						headerContent: options.headerContent,
						centerContent: options.centerContent,
						leftContent: options.leftContent,
						rightContent: options.rightContent,
						footerContent: options.footerContent
					}, options);

					var body = $('body');
					var hgHeader = $('<div>').attr({ id: 'hg-header' });
					var hgContainer = $('<div>').attr({ id: 'hg-container' });
					var hgCenter = $('<div>').attr({ id: 'hg-center', 'class': 'hg-column' });
					var hgLeft = $('<div>').attr({ id: 'hg-left', 'class': 'hg-column' });
					var hgRight = $('<div>').attr({ id: 'hg-right', 'class': 'hg-column' });
					var hgFooter = $('<div>').attr({ id: 'hg-footer' });

					$(hgContainer).append(hgCenter);
					$(hgContainer).append(hgLeft);
					$(hgContainer).append(hgRight);
					$(body).append(hgHeader);
					$(body).append(hgContainer);
					$(body).append(hgFooter);

					$(this.headerContent).attr({ 'class': 'hg-pad' });
					$(this.centerContent).attr({ 'class': 'hg-pad' });
					$(this.leftContent).attr({ 'class': 'hg-pad' });
					$(this.rightContent).attr({ 'class': 'hg-pad' });
					$(this.footerContent).attr({ 'class': 'hg-pad' });

					$(hgHeader).append($(settings.headerContent));
					$(hgCenter).append($(settings.centerContent));
					$(hgLeft).append($(settings.leftContent));
					$(hgRight).append($(settings.rightContent));
					$(hgFooter).append($(settings.footerContent));
				}
			}(jQuery));
		</div></div></div></div></div></div></reference>

반응형
반응형

CSS - Cheat sheet

 

 

반응형
반응형

Cardinal — Mobile-first CSS framework with useful defaults

Cardinal is a mobile-first CSS framework that comes with some useful default styles, reusable modules, scalable typography, and a responsive grid system. It’s great for developers who want a simpler way to build responsive web apps.

cardinal

 

반응형
반응형

[CSS] css 참고 사이트.   transform, transition, Animation

 

CSS3 transform:skew
CSS3 transform:rotate
CSS3 transform-origin

 

transform
transition
animation

 

http://tcbs17.cafe24.com/tc/html5/css_/css_demo2/index.html


SVG : Scalable Vector Graphics

 

CSS 참고 사이트
http://htmlcss.kr/
http://w3schools.com/
http://css3generator.com/
http://caniuse.com/

반응형
반응형

 

17 Best CSS Tools to Speed Up Your Coding

 

http://codegeekz.com/best-css-tools-to-speed-up-your-coding/

 

CSS doesn’t need any introduction as it is one of the most popular language amongst developers. Learning and working with CSS is no more an arduous task as there are many informative tutorials and CSS tools are available over Internet. Such tools would lead you to create useful and innovative web applications and spare the development process and time.

In this article I have gathered 17 Best CSS Tools to speed up your coding; following tools will assist and simplify the work of developers and designers. With the following tools you can generate CSS menus, animated images, buttons, sliders, text animation, CSS form codes, layers and many more. Hope you find the list handy and useful for your development needs.

1. Topcoat : CSS for Clean and Fast Web Apps

topcoat
Topcoat is a library which consists CSS classes for form elements, buttons, checkboxes, sliders and many more. It is a lightweight tool that would make your website or app look awesome in short period of time.

Website

2. PCSS : Shortcut Oriented Server Side CSS3 Preprocessor

pcss
PCSS is a PHP-driven CSS Preprocessor, which aids developer to write CSS code quickly by defining variables, class nesting, default unit and server-side browser specifics. PCSS do server-side processing using PHP 5, so it requires this version to be available on the server where the website is running.

Website

3. Skelton

skelton
Skeleton is a small collection of CSS files that can help you rapidly develop sites that look beautiful at any size, be it a 17″ laptop screen or an iPhone. Skeleton is built on three core principles: responsive grid down to mobile, fast to start and style agnostic.

Website

4. CSS Menu Maker

css-menu-maker
This tool helps users to create custom CSS drop down menu easily. CSS Menu Maker provides webmaster with tools to create custom, cross browser compatible css menus also it provides source code for all CSS Menus and facilities users to download and tweak the code.

Website

5. Sencha Animator

sencha
It is a desktop application which enables users to create CSS3 animations for touch screen mobile devices and webkit browsers. Sencha Animator helps users to create animated text, images, design buttons with gradients and embed analytics.

Website

6. CSS Form Code Generator

css-form-generator
CSS Form Code maker creates nice looking layouts for forms. It also helps you to crate colorful table less layout for forms. This ‘code maker’ generates CSS layout code to ‘spice up’ those forms as well.

Website

7. PrefixmyCSS

prefixmycss
PrefixMyCss lets you prefix your CSS3 code easily. Users have to paste CSS code in to the window to prefix, all vendor prefixes are added to your code, users can safely replace their old code.

Website

8. Sky CSS Tool

sky-css-tool
Sky CSS Tool allows you to create CSS classes almost without using manuscript code. Users would need JavaScript compatible browser for the proper functioning.

Website

9. Spritemapper

Spritemapper
Spritemapper is an application that merges multiple images into one and generates CSS positioning for the corresponding slices. This tool helps developers to optimize available space and the loading time.

Website

10. CSS Compressor

css_drive
CSS Compressor compresses your CSS to increase loading speed and save on bandwidth as well. You can choose from three levels of compression, depending on how legible you want the compressed CSS to be versus degree of compression.

Website

11. Patternify

Patternify
It helps you to generate beautiful CSS patterns.

Website

12. CSS Text Shadow

Css Text Shadow
CSS Text Shadow allows you to generate beautiful text shadows.

Website

13. CSS3 Pie

CSS3-PIE
Pie makes internet explorer 6-9 capable of rendering several of the most useful CSS3 decoration features.

Website

14. The Web Font Combinator

font-combinator
This tool has been built to allow previewing of font combinations in a fast, browser-based manner. There have been numerous printed books through the years that allowed a designer to put a headline font next to a body font, and this is an attempt to recreate that for the web.

Website

15. 3D Transforms

3d transform
CSS 3D Transforms is online tool which enables users to perform various level Transforms. This tool is on experimental mode and require specify prefixes in all browsers.

Website

16. Quick Form Builder

accessify
Quick Form Builder allows you to easily create CSS forms.

Website

17. Layer Styles

layerstyles
It is a HTML5 app for creating CSS3 in an intuitive way. It has Colorpicker which lets you pick any color of the element you’re working on, it facilitates users with Drag and Drop images on to the page to use them as background or to pick their colors.

Website

반응형
반응형

Pure — Small, responsive CSS modules for every project

 

Homepage: http://purecss.io/
GitHub: https://github.com/yui/pure/

 

Pure는 설치가 간단한, 반응형 CSS 모듈이다.

 

Pure is a set of small, responsive CSS modules that can be used in all of your web projects.

 There are modules for everything from grids to forms to menus and much more,

all with a minimal footprint (ranging from .6KB for the tables module to 1.4KB for the forms module).

 

 

 

 

 

 

반응형

+ Recent posts