activoate 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README +3 -0
- data/Rakefile +1 -0
- data/activoate.gemspec +25 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/images/.DS_Store +0 -0
- data/app/assets/images/activo-2/.DS_Store +0 -0
- data/app/assets/images/activo-2/arrow.png +0 -0
- data/app/assets/images/activo-2/avatar.png +0 -0
- data/app/assets/images/activo-2/bgd.jpg +0 -0
- data/app/assets/images/activo-2/boxbar-background.png +0 -0
- data/app/assets/images/activo-2/breadcrumb.png +0 -0
- data/app/assets/images/activo-2/button-background-active.png +0 -0
- data/app/assets/images/activo-2/button-background.png +0 -0
- data/app/assets/images/activo-2/icons/24/about-this-folder.txt +12 -0
- data/app/assets/images/activo-2/icons/24/anchor-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/anchor.png +0 -0
- data/app/assets/images/activo-2/icons/24/cross-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/cross.png +0 -0
- data/app/assets/images/activo-2/icons/24/download-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/download.png +0 -0
- data/app/assets/images/activo-2/icons/24/edit-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/edit.png +0 -0
- data/app/assets/images/activo-2/icons/24/export-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/export.png +0 -0
- data/app/assets/images/activo-2/icons/24/show-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/show.png +0 -0
- data/app/assets/images/activo-2/icons/about-this-folder.txt +1 -0
- data/app/assets/images/activo-2/icons/add.png +0 -0
- data/app/assets/images/activo-2/icons/application_edit.png +0 -0
- data/app/assets/images/activo-2/icons/calendar-hover.png +0 -0
- data/app/assets/images/activo-2/icons/calendar.png +0 -0
- data/app/assets/images/activo-2/icons/cross.png +0 -0
- data/app/assets/images/activo-2/icons/delete.png +0 -0
- data/app/assets/images/activo-2/icons/download.png +0 -0
- data/app/assets/images/activo-2/icons/edit.png +0 -0
- data/app/assets/images/activo-2/icons/key.png +0 -0
- data/app/assets/images/activo-2/icons/pdf.png +0 -0
- data/app/assets/images/activo-2/icons/search.png +0 -0
- data/app/assets/images/activo-2/icons/see-less.png +0 -0
- data/app/assets/images/activo-2/icons/see-more.png +0 -0
- data/app/assets/images/activo-2/icons/send-mail.png +0 -0
- data/app/assets/images/activo-2/icons/show.png +0 -0
- data/app/assets/images/activo-2/icons/tick.png +0 -0
- data/app/assets/images/activo-2/icons/upload.png +0 -0
- data/app/assets/images/activo-2/logo.png +0 -0
- data/app/assets/images/activo-2/messages/error.png +0 -0
- data/app/assets/images/activo-2/messages/notice.png +0 -0
- data/app/assets/images/activo-2/messages/warning.png +0 -0
- data/app/assets/images/activo-2/search-button.png +0 -0
- data/app/assets/images/activo-2/session/about-this-folder.txt +1 -0
- data/app/assets/images/activo-2/session/account.png +0 -0
- data/app/assets/images/activo-2/session/config.png +0 -0
- data/app/assets/images/activo-2/session/home.png +0 -0
- data/app/assets/images/activo-2/session/logout.png +0 -0
- data/app/assets/images/activo-2/tipsy/tipsy.gif +0 -0
- data/app/assets/images/activo-2/uniform/bg-input-focus.png +0 -0
- data/app/assets/images/activo-2/uniform/bg-input.png +0 -0
- data/app/assets/images/activo-2/uniform/sprite.png +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/activo-2/activo-2.js +81 -0
- data/app/assets/javascripts/activo-2/jquery.localscroll.js +104 -0
- data/app/assets/javascripts/activo-2/jquery.scrollTo.js +150 -0
- data/app/assets/javascripts/activo-2/jquery.tipsy.js +104 -0
- data/app/assets/javascripts/activo-2/jquery.uniform.min.js +1 -0
- data/app/assets/javascripts/activo-2.js +10 -0
- data/app/assets/javascripts/users.js.coffee +3 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/attrtastic_changes.sass +62 -0
- data/app/assets/stylesheets/activo-2/base.css +390 -0
- data/app/assets/stylesheets/activo-2/fonts/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.svg +242 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.svg +240 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.svg +240 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts.sass +49 -0
- data/app/assets/stylesheets/activo-2/formtastic_changes.sass +157 -0
- data/app/assets/stylesheets/activo-2/libs/jquery.tipsy.css +9 -0
- data/app/assets/stylesheets/activo-2/libs/uniform.default.css +610 -0
- data/app/assets/stylesheets/activo-2/mixins.sass +22 -0
- data/app/assets/stylesheets/activo-2/style.sass +666 -0
- data/app/assets/stylesheets/activo-2.css +11 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/scaffolds.css.scss +56 -0
- data/app/assets/stylesheets/users.css.scss +3 -0
- data/app/helpers/activo_helper.rb +290 -0
- data/config.ru +4 -0
- data/lib/activoate/engine.rb +6 -0
- data/lib/activoate/version.rb +3 -0
- data/lib/activoate.rb +5 -0
- data/lib/generators/activoate/activated/activated_generator.rb +140 -0
- data/lib/generators/activoate/activated/templates/view_edit.html.erb +17 -0
- data/lib/generators/activoate/activated/templates/view_form.html.erb +16 -0
- data/lib/generators/activoate/activated/templates/view_form_formtastic.html.erb +18 -0
- data/lib/generators/activoate/activated/templates/view_new.html.erb +16 -0
- data/lib/generators/activoate/activated/templates/view_show.html.erb +26 -0
- data/lib/generators/activoate/activated/templates/view_show_attrtastic.html.erb +27 -0
- data/lib/generators/activoate/activated/templates/view_sidebar.html.erb +13 -0
- data/lib/generators/activoate/activated/templates/view_signin.html.erb +36 -0
- data/lib/generators/activoate/activated/templates/view_signup.html.erb +52 -0
- data/lib/generators/activoate/activated/templates/view_tables.html.erb +56 -0
- data/lib/generators/activoate/activated/templates/view_text.html.erb +18 -0
- data/lib/generators/activoate/install/install_generator.rb +40 -0
- data/lib/generators/activoate/install/templates/layout_admin.html.erb +49 -0
- data/lib/templates/web_app_theme/theme/layout_admin.html.erb +57 -0
- data/lib/templates/web_app_theme/theme/layout_sign.html.erb +15 -0
- data/lib/templates/web_app_theme/theme/web_app_theme.css.erb +9 -0
- metadata +197 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/Gemfile
ADDED
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/activoate.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "activoate/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "activoate"
|
7
|
+
s.version = Activoate::VERSION
|
8
|
+
s.authors = ["Alan Sikora"]
|
9
|
+
s.email = ["alan@wcd.co"]
|
10
|
+
s.homepage = "https://github.com/wcdcompany/activoate"
|
11
|
+
s.summary = "Helps to use Activo 2 theme on Rails 3 applications."
|
12
|
+
s.description = "Helps to use Activo 2 theme on Rails 3 applications and provides handy helpers and generators to use with formtastic/attrtastic"
|
13
|
+
|
14
|
+
s.rubyforge_project = "activoate"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_dependency 'rails', '>= 3.0.0'
|
23
|
+
s.add_dependency 'attrtastic'
|
24
|
+
s.add_dependency 'formtastic'
|
25
|
+
end
|
data/app/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
The icons listed here belong to the "Fugue Icons" library available at "http://p.yusukekamiyamane.com".
|
2
|
+
|
3
|
+
To add a new icon, enlarge the icon canvas to 24x24 pixels.
|
4
|
+
Give it the name 'action-hover.png', where 'action' is the name of the action related to the button.
|
5
|
+
|
6
|
+
To create an icon 'action.png' using an icon 'action-hover.png' do the following steps:
|
7
|
+
- Transparency 40%
|
8
|
+
- Saturation -30 (in a range between -100 and 100)
|
9
|
+
- Brightness +30 (in a range between -100 and 100)
|
10
|
+
- Yellow channel -20 (color_balance tool, in a range between -100 and 100).
|
11
|
+
|
12
|
+
Gimp was used to create this.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
The icons listed here belong to the "Fugue Icons" library available at "http://p.yusukekamiyamane.com".
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
The icons listed here were made using the Glyphish iconset available at "http://http://glyphish.com/" and the "Wireframe Toolbar" icons available at "http://gentleface.com/free_icon_set.html"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
(function($) {
|
2
|
+
$(document).ready(function()
|
3
|
+
{
|
4
|
+
// jQuery uniform controls (http://pixelmatrixdesign.com/uniform)
|
5
|
+
$(".formtastic select, .formtastic input:checkbox, .formtastic input:radio, .formtastic input:file").uniform();
|
6
|
+
|
7
|
+
// jQuery datepicker for formtastic (http://gist.github.com/271377)
|
8
|
+
$('input.ui-datepicker-input').datepicker({ dateFormat: 'dd-mm-yy' });
|
9
|
+
|
10
|
+
// Tooltips (http://onehackoranother.com/projects/jquery/tipsy)
|
11
|
+
$('img').each( function() {
|
12
|
+
if ($(this).get(0).title != '') {
|
13
|
+
$(this).tipsy();
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
// Scroll effect for anchors (http://flesler.blogspot.com/2007/10/jqueryscrollto.html)
|
18
|
+
$('a').click(function() {
|
19
|
+
if ($(this).attr('class') == 'anchor') {
|
20
|
+
$.scrollTo(this.hash, 500);
|
21
|
+
$(this.hash).find('span.message').text(this.href);
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
// Initialize jQuery UI widgets for theme preview
|
27
|
+
// Accordion
|
28
|
+
$("#accordion").accordion({ header: "h4" });
|
29
|
+
// Autocomplete
|
30
|
+
$("#autocomplete").autocomplete({
|
31
|
+
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]
|
32
|
+
});
|
33
|
+
// Button
|
34
|
+
$("#button").button();
|
35
|
+
$("#radioset").buttonset();
|
36
|
+
// Tabs
|
37
|
+
$('#tabs').tabs();
|
38
|
+
// Dialog
|
39
|
+
$('#dialog').dialog({
|
40
|
+
autoOpen: false,
|
41
|
+
width: 600,
|
42
|
+
buttons: {
|
43
|
+
"Ok": function() {
|
44
|
+
$(this).dialog("close");
|
45
|
+
},
|
46
|
+
"Cancel": function() {
|
47
|
+
$(this).dialog("close");
|
48
|
+
}
|
49
|
+
}
|
50
|
+
});
|
51
|
+
// Dialog Link
|
52
|
+
$('#dialog_link').button({
|
53
|
+
icons: {
|
54
|
+
primary: "ui-icon-newwin"
|
55
|
+
}
|
56
|
+
});
|
57
|
+
$('#dialog_link').click(function(){
|
58
|
+
$('#dialog').dialog('open');
|
59
|
+
return false;
|
60
|
+
});
|
61
|
+
// Datepicker
|
62
|
+
$('#datepicker').datepicker({
|
63
|
+
inline: true
|
64
|
+
});
|
65
|
+
// Slider
|
66
|
+
$('#slider').slider({
|
67
|
+
range: true,
|
68
|
+
values: [17, 67]
|
69
|
+
});
|
70
|
+
// Progressbar
|
71
|
+
$("#progressbar").progressbar({
|
72
|
+
value: 20
|
73
|
+
});
|
74
|
+
//hover states on the static widgets
|
75
|
+
$('#dialog_link, ul#icons li').hover(
|
76
|
+
function() { $(this).addClass('ui-state-hover'); },
|
77
|
+
function() { $(this).removeClass('ui-state-hover'); }
|
78
|
+
);
|
79
|
+
|
80
|
+
});
|
81
|
+
})(jQuery)
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery.LocalScroll
|
3
|
+
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
4
|
+
* Dual licensed under MIT and GPL.
|
5
|
+
* Date: 6/3/2008
|
6
|
+
*
|
7
|
+
* @projectDescription Animated scrolling navigation, using anchors.
|
8
|
+
* http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
|
9
|
+
* @author Ariel Flesler
|
10
|
+
* @version 1.2.6
|
11
|
+
*
|
12
|
+
* @id jQuery.fn.localScroll
|
13
|
+
* @param {Object} settings Hash of settings, it is passed in to jQuery.ScrollTo, none is required.
|
14
|
+
* @return {jQuery} Returns the same jQuery object, for chaining.
|
15
|
+
*
|
16
|
+
* @example $('ul.links').localScroll();
|
17
|
+
*
|
18
|
+
* @example $('ul.links').localScroll({ filter:'.animated', duration:400, axis:'x' });
|
19
|
+
*
|
20
|
+
* @example $.localScroll({ target:'#pane', axis:'xy', queue:true, event:'mouseover' });
|
21
|
+
*
|
22
|
+
* Notes:
|
23
|
+
* - The plugin requires jQuery.ScrollTo.
|
24
|
+
* - The hash of settings, is passed to jQuery.ScrollTo, so the settings are valid for that plugin as well.
|
25
|
+
* - jQuery.localScroll can be used if the desired links, are all over the document, it accepts the same settings.
|
26
|
+
* - If the setting 'lazy' is set to true, then the binding will still work for later added anchors.
|
27
|
+
* - The setting 'speed' is deprecated, use 'duration' instead.
|
28
|
+
* - If onBefore returns false, the event is ignored.
|
29
|
+
**/
|
30
|
+
;(function( $ ){
|
31
|
+
var URI = location.href.replace(/#.*/,'');//local url without hash
|
32
|
+
|
33
|
+
var $localScroll = $.localScroll = function( settings ){
|
34
|
+
$('body').localScroll( settings );
|
35
|
+
};
|
36
|
+
|
37
|
+
//Many of these defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
|
38
|
+
//@see http://www.freewebs.com/flesler/jQuery.ScrollTo/
|
39
|
+
$localScroll.defaults = {//the defaults are public and can be overriden.
|
40
|
+
duration:1000, //how long to animate.
|
41
|
+
axis:'y',//which of top and left should be modified.
|
42
|
+
event:'click',//on which event to react.
|
43
|
+
stop:true//avoid queuing animations
|
44
|
+
/*
|
45
|
+
lock:false,//ignore events if already animating
|
46
|
+
lazy:false,//if true, links can be added later, and will still work.
|
47
|
+
target:null, //what to scroll (selector or element). Keep it null if want to scroll the whole window.
|
48
|
+
filter:null, //filter some anchors out of the matched elements.
|
49
|
+
hash: false//if true, the hash of the selected link, will appear on the address bar.
|
50
|
+
*/
|
51
|
+
};
|
52
|
+
|
53
|
+
//if the URL contains a hash, it will scroll to the pointed element
|
54
|
+
$localScroll.hash = function( settings ){
|
55
|
+
settings = $.extend( {}, $localScroll.defaults, settings );
|
56
|
+
settings.hash = false;//can't be true
|
57
|
+
if( location.hash )
|
58
|
+
setTimeout(function(){ scroll( 0, location, settings ); }, 0 );//better wrapped with a setTimeout
|
59
|
+
};
|
60
|
+
|
61
|
+
$.fn.localScroll = function( settings ){
|
62
|
+
settings = $.extend( {}, $localScroll.defaults, settings );
|
63
|
+
|
64
|
+
return ( settings.persistent || settings.lazy )
|
65
|
+
? this.bind( settings.event, function( e ){//use event delegation, more links can be added later.
|
66
|
+
var a = $([e.target, e.target.parentNode]).filter(filter)[0];//if a valid link was clicked.
|
67
|
+
a && scroll( e, a, settings );//do scroll.
|
68
|
+
})
|
69
|
+
: this.find('a,area')//bind concretely, to each matching link
|
70
|
+
.filter( filter ).bind( settings.event, function(e){
|
71
|
+
scroll( e, this, settings );
|
72
|
+
}).end()
|
73
|
+
.end();
|
74
|
+
|
75
|
+
function filter(){//is this a link that points to an anchor and passes a possible filter ? href is checked to avoid a bug in FF.
|
76
|
+
return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is( settings.filter ));
|
77
|
+
};
|
78
|
+
};
|
79
|
+
|
80
|
+
function scroll( e, link, settings ){
|
81
|
+
var id = link.hash.slice(1),
|
82
|
+
elem = document.getElementById(id) || document.getElementsByName(id)[0];
|
83
|
+
if ( elem ){
|
84
|
+
e && e.preventDefault();
|
85
|
+
var $target = $( settings.target || $.scrollTo.window() );//if none specified, then the window.
|
86
|
+
|
87
|
+
if( settings.lock && $target.is(':animated') ||
|
88
|
+
settings.onBefore && settings.onBefore.call(link, e, elem, $target) === false ) return;
|
89
|
+
|
90
|
+
if( settings.stop )
|
91
|
+
$target.queue('fx',[]).stop();//remove all its animations
|
92
|
+
$target
|
93
|
+
.scrollTo( elem, settings )//do scroll
|
94
|
+
.trigger('notify.serialScroll',[elem]);//notify serialScroll about this change
|
95
|
+
if( settings.hash )
|
96
|
+
$target.queue(function(){
|
97
|
+
location = link.hash;
|
98
|
+
// make sure this function is released
|
99
|
+
$(this).dequeue();
|
100
|
+
});
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
104
|
+
})( jQuery );
|
@@ -0,0 +1,150 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery.ScrollTo
|
3
|
+
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
4
|
+
* Dual licensed under MIT and GPL.
|
5
|
+
* Date: 2/19/2008
|
6
|
+
*
|
7
|
+
* @projectDescription Easy element scrolling using jQuery.
|
8
|
+
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
9
|
+
* Tested with jQuery 1.2.1. On FF 2.0.0.11, IE 6, Opera 9.22 and Safari 3 beta. on Windows.
|
10
|
+
*
|
11
|
+
* @author Ariel Flesler
|
12
|
+
* @version 1.3.3
|
13
|
+
*
|
14
|
+
* @id jQuery.scrollTo
|
15
|
+
* @id jQuery.fn.scrollTo
|
16
|
+
* @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
|
17
|
+
* The different options for target are:
|
18
|
+
* - A number position (will be applied to all axes).
|
19
|
+
* - A string position ('44', '100px', '+=90', etc ) will be applied to all axes
|
20
|
+
* - A jQuery/DOM element ( logically, child of the element to scroll )
|
21
|
+
* - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
|
22
|
+
* - A hash { top:x, left:y }, x and y can be any kind of number/string like above.
|
23
|
+
* @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
|
24
|
+
* @param {Object} settings Hash of settings, optional.
|
25
|
+
* @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
|
26
|
+
* @option {Number} duration The OVERALL length of the animation.
|
27
|
+
* @option {String} easing The easing method for the animation.
|
28
|
+
* @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
|
29
|
+
* @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
|
30
|
+
* @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
|
31
|
+
* @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
|
32
|
+
* @option {Function} onAfter Function to be called after the scrolling ends.
|
33
|
+
* @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
|
34
|
+
* @return {jQuery} Returns the same jQuery object, for chaining.
|
35
|
+
*
|
36
|
+
* @example $('div').scrollTo( 340 );
|
37
|
+
*
|
38
|
+
* @example $('div').scrollTo( '+=340px', { axis:'y' } );
|
39
|
+
*
|
40
|
+
* @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
|
41
|
+
*
|
42
|
+
* @example var second_child = document.getElementById('container').firstChild.nextSibling;
|
43
|
+
* $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
|
44
|
+
* alert('scrolled!!');
|
45
|
+
* }});
|
46
|
+
*
|
47
|
+
* @example $('div').scrollTo( { top: 300, left:'+=200' }, { offset:-20 } );
|
48
|
+
*
|
49
|
+
* Notes:
|
50
|
+
* - jQuery.scrollTo will make the whole window scroll, it accepts the same arguments as jQuery.fn.scrollTo.
|
51
|
+
* - If you are interested in animated anchor navigation, check http://jquery.com/plugins/project/LocalScroll.
|
52
|
+
* - The options margin, offset and over are ignored, if the target is not a jQuery object or a DOM element.
|
53
|
+
* - The option 'queue' won't be taken into account, if only 1 axis is given.
|
54
|
+
*/
|
55
|
+
;(function( $ ){
|
56
|
+
|
57
|
+
var $scrollTo = $.scrollTo = function( target, duration, settings ){
|
58
|
+
$scrollTo.window().scrollTo( target, duration, settings );
|
59
|
+
};
|
60
|
+
|
61
|
+
$scrollTo.defaults = {
|
62
|
+
axis:'y',
|
63
|
+
duration:1
|
64
|
+
};
|
65
|
+
|
66
|
+
//returns the element that needs to be animated to scroll the window
|
67
|
+
$scrollTo.window = function(){
|
68
|
+
return $( $.browser.safari ? 'body' : 'html' );
|
69
|
+
};
|
70
|
+
|
71
|
+
$.fn.scrollTo = function( target, duration, settings ){
|
72
|
+
if( typeof duration == 'object' ){
|
73
|
+
settings = duration;
|
74
|
+
duration = 0;
|
75
|
+
}
|
76
|
+
settings = $.extend( {}, $scrollTo.defaults, settings );
|
77
|
+
duration = duration || settings.speed || settings.duration;//speed is still recognized for backwards compatibility
|
78
|
+
settings.queue = settings.queue && settings.axis.length > 1;//make sure the settings are given right
|
79
|
+
if( settings.queue )
|
80
|
+
duration /= 2;//let's keep the overall speed, the same.
|
81
|
+
settings.offset = both( settings.offset );
|
82
|
+
settings.over = both( settings.over );
|
83
|
+
|
84
|
+
return this.each(function(){
|
85
|
+
var elem = this, $elem = $(elem),
|
86
|
+
t = target, toff, attr = {},
|
87
|
+
win = $elem.is('html,body');
|
88
|
+
switch( typeof t ){
|
89
|
+
case 'number'://will pass the regex
|
90
|
+
case 'string':
|
91
|
+
if( /^([+-]=)?\d+(px)?$/.test(t) ){
|
92
|
+
t = both( t );
|
93
|
+
break;//we are done
|
94
|
+
}
|
95
|
+
t = $(t,this);// relative selector, no break!
|
96
|
+
case 'object':
|
97
|
+
if( t.is || t.style )//DOM/jQuery
|
98
|
+
toff = (t = $(t)).offset();//get the real position of the target
|
99
|
+
}
|
100
|
+
$.each( settings.axis.split(''), function( i, axis ){
|
101
|
+
var Pos = axis == 'x' ? 'Left' : 'Top',
|
102
|
+
pos = Pos.toLowerCase(),
|
103
|
+
key = 'scroll' + Pos,
|
104
|
+
act = elem[key],
|
105
|
+
Dim = axis == 'x' ? 'Width' : 'Height',
|
106
|
+
dim = Dim.toLowerCase();
|
107
|
+
|
108
|
+
if( toff ){//jQuery/DOM
|
109
|
+
attr[key] = toff[pos] + ( win ? 0 : act - $elem.offset()[pos] );
|
110
|
+
|
111
|
+
if( settings.margin ){//if it's a dom element, reduce the margin
|
112
|
+
attr[key] -= parseInt(t.css('margin'+Pos)) || 0;
|
113
|
+
attr[key] -= parseInt(t.css('border'+Pos+'Width')) || 0;
|
114
|
+
}
|
115
|
+
|
116
|
+
attr[key] += settings.offset[pos] || 0;//add/deduct the offset
|
117
|
+
|
118
|
+
if( settings.over[pos] )//scroll to a fraction of its width/height
|
119
|
+
attr[key] += t[dim]() * settings.over[pos];
|
120
|
+
}else
|
121
|
+
attr[key] = t[pos];//remove the unnecesary 'px'
|
122
|
+
|
123
|
+
if( /^\d+$/.test(attr[key]) )//number or 'number'
|
124
|
+
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) );//check the limits
|
125
|
+
|
126
|
+
if( !i && settings.queue ){//queueing each axis is required
|
127
|
+
if( act != attr[key] )//don't waste time animating, if there's no need.
|
128
|
+
animate( settings.onAfterFirst );//intermediate animation
|
129
|
+
delete attr[key];//don't animate this axis again in the next iteration.
|
130
|
+
}
|
131
|
+
});
|
132
|
+
animate( settings.onAfter );
|
133
|
+
|
134
|
+
function animate( callback ){
|
135
|
+
$elem.animate( attr, duration, settings.easing, callback && function(){
|
136
|
+
callback.call(this, target);
|
137
|
+
});
|
138
|
+
};
|
139
|
+
function max( Dim ){
|
140
|
+
var el = win ? $.browser.opera ? document.body : document.documentElement : elem;
|
141
|
+
return el['scroll'+Dim] - el['client'+Dim];
|
142
|
+
};
|
143
|
+
});
|
144
|
+
};
|
145
|
+
|
146
|
+
function both( val ){
|
147
|
+
return typeof val == 'object' ? val : { top:val, left:val };
|
148
|
+
};
|
149
|
+
|
150
|
+
})( jQuery );
|
@@ -0,0 +1,104 @@
|
|
1
|
+
(function($) {
|
2
|
+
$.fn.tipsy = function(options) {
|
3
|
+
|
4
|
+
options = $.extend({}, $.fn.tipsy.defaults, options);
|
5
|
+
|
6
|
+
return this.each(function() {
|
7
|
+
|
8
|
+
var opts = $.fn.tipsy.elementOptions(this, options);
|
9
|
+
|
10
|
+
$(this).hover(function() {
|
11
|
+
|
12
|
+
$.data(this, 'cancel.tipsy', true);
|
13
|
+
|
14
|
+
var tip = $.data(this, 'active.tipsy');
|
15
|
+
if (!tip) {
|
16
|
+
tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>');
|
17
|
+
tip.css({position: 'absolute', zIndex: 100000});
|
18
|
+
$.data(this, 'active.tipsy', tip);
|
19
|
+
}
|
20
|
+
|
21
|
+
if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
|
22
|
+
$(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
|
23
|
+
}
|
24
|
+
|
25
|
+
var title;
|
26
|
+
if (typeof opts.title == 'string') {
|
27
|
+
title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
|
28
|
+
} else if (typeof opts.title == 'function') {
|
29
|
+
title = opts.title.call(this);
|
30
|
+
}
|
31
|
+
|
32
|
+
tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);
|
33
|
+
|
34
|
+
var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
|
35
|
+
tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity
|
36
|
+
tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
|
37
|
+
var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
|
38
|
+
var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;
|
39
|
+
|
40
|
+
switch (gravity.charAt(0)) {
|
41
|
+
case 'n':
|
42
|
+
tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
|
43
|
+
break;
|
44
|
+
case 's':
|
45
|
+
tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
|
46
|
+
break;
|
47
|
+
case 'e':
|
48
|
+
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
|
49
|
+
break;
|
50
|
+
case 'w':
|
51
|
+
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
|
52
|
+
break;
|
53
|
+
}
|
54
|
+
|
55
|
+
if (opts.fade) {
|
56
|
+
tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8});
|
57
|
+
} else {
|
58
|
+
tip.css({visibility: 'visible'});
|
59
|
+
}
|
60
|
+
|
61
|
+
}, function() {
|
62
|
+
$.data(this, 'cancel.tipsy', false);
|
63
|
+
var self = this;
|
64
|
+
setTimeout(function() {
|
65
|
+
if ($.data(this, 'cancel.tipsy')) return;
|
66
|
+
var tip = $.data(self, 'active.tipsy');
|
67
|
+
if (opts.fade) {
|
68
|
+
tip.stop().fadeOut(function() { $(this).remove(); });
|
69
|
+
} else {
|
70
|
+
tip.remove();
|
71
|
+
}
|
72
|
+
}, 100);
|
73
|
+
|
74
|
+
});
|
75
|
+
|
76
|
+
});
|
77
|
+
|
78
|
+
};
|
79
|
+
|
80
|
+
// Overwrite this method to provide options on a per-element basis.
|
81
|
+
// For example, you could store the gravity in a 'tipsy-gravity' attribute:
|
82
|
+
// return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
|
83
|
+
// (remember - do not modify 'options' in place!)
|
84
|
+
$.fn.tipsy.elementOptions = function(ele, options) {
|
85
|
+
return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
|
86
|
+
};
|
87
|
+
|
88
|
+
$.fn.tipsy.defaults = {
|
89
|
+
fade: false,
|
90
|
+
fallback: '',
|
91
|
+
gravity: 'n',
|
92
|
+
html: false,
|
93
|
+
title: 'title'
|
94
|
+
};
|
95
|
+
|
96
|
+
$.fn.tipsy.autoNS = function() {
|
97
|
+
return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
|
98
|
+
};
|
99
|
+
|
100
|
+
$.fn.tipsy.autoWE = function() {
|
101
|
+
return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
|
102
|
+
};
|
103
|
+
|
104
|
+
})(jQuery);
|