olelo 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.gitmodules +3 -0
- data/Gemfile +3 -0
- data/README.markdown +104 -0
- data/Rakefile +92 -0
- data/bin/olelo +5 -0
- data/config.ru +86 -0
- data/config/aspects.rb +256 -0
- data/config/config.yml.default +154 -0
- data/config/initializers/00-mime_types.rb +29 -0
- data/config/initializers/01-slim.rb +2 -0
- data/config/interwiki.yml +11 -0
- data/doc/AUTHORS +7 -0
- data/doc/LICENSE +22 -0
- data/lib/olelo.rb +39 -0
- data/lib/olelo/application.rb +294 -0
- data/lib/olelo/attributes.rb +285 -0
- data/lib/olelo/config.rb +88 -0
- data/lib/olelo/extensions.rb +252 -0
- data/lib/olelo/helper.rb +290 -0
- data/lib/olelo/hooks.rb +142 -0
- data/lib/olelo/html_safe.rb +29 -0
- data/lib/olelo/initializer.rb +76 -0
- data/lib/olelo/locale.rb +63 -0
- data/lib/olelo/locale.yml +284 -0
- data/lib/olelo/menu.rb +101 -0
- data/lib/olelo/middleware/blacklist.rb +25 -0
- data/lib/olelo/middleware/degrade_mime_type.rb +19 -0
- data/lib/olelo/middleware/flash.rb +97 -0
- data/lib/olelo/middleware/force_encoding.rb +41 -0
- data/lib/olelo/page.rb +266 -0
- data/lib/olelo/patch.rb +311 -0
- data/lib/olelo/plugin.rb +188 -0
- data/lib/olelo/repository.rb +225 -0
- data/lib/olelo/routing.rb +223 -0
- data/lib/olelo/templates.rb +30 -0
- data/lib/olelo/user.rb +132 -0
- data/lib/olelo/util.rb +233 -0
- data/lib/olelo/version.rb +3 -0
- data/lib/olelo/virtualfs.rb +161 -0
- data/lib/rack/olelo_patches.rb +33 -0
- data/lib/rack/relative_redirect.rb +44 -0
- data/lib/rack/static_cache.rb +93 -0
- data/lib/yard/addons.rb +1 -0
- data/lib/yard/addons/hook_handler.rb +25 -0
- data/lib/yard/addons/override_tag.rb +14 -0
- data/lib/yard/addons/route_handler.rb +33 -0
- data/lib/yard/addons/sanitize_anchor.rb +16 -0
- data/olelo.gemspec +31 -0
- data/plugins/aspects/changelog.rb +45 -0
- data/plugins/aspects/documentbrowser.rb +57 -0
- data/plugins/aspects/download.rb +11 -0
- data/plugins/aspects/highlight.rb +8 -0
- data/plugins/aspects/image.rb +41 -0
- data/plugins/aspects/imageinfo.rb +64 -0
- data/plugins/aspects/locale.yml +60 -0
- data/plugins/aspects/main.rb +199 -0
- data/plugins/aspects/pageinfo.rb +37 -0
- data/plugins/aspects/source.rb +6 -0
- data/plugins/aspects/subpages.rb +44 -0
- data/plugins/aspects/text.rb +9 -0
- data/plugins/blog/blog.css +1 -0
- data/plugins/blog/blog.scss +37 -0
- data/plugins/blog/locale.yml +12 -0
- data/plugins/blog/main.rb +85 -0
- data/plugins/editor/locale.yml +18 -0
- data/plugins/editor/markup/main.rb +3 -0
- data/plugins/editor/markup/script.js +10 -0
- data/plugins/editor/markup/script/00-jquery.textselection.js +267 -0
- data/plugins/editor/markup/script/01-olelo.markupeditor.js +116 -0
- data/plugins/editor/markup/script/init.js +10 -0
- data/plugins/editor/preview.rb +52 -0
- data/plugins/editor/recaptcha.rb +56 -0
- data/plugins/filters/creole.rb +37 -0
- data/plugins/filters/disposition.rb +9 -0
- data/plugins/filters/editsection.rb +67 -0
- data/plugins/filters/fix_img_tag.rb +16 -0
- data/plugins/filters/html_wrapper.rb +12 -0
- data/plugins/filters/interwiki.rb +19 -0
- data/plugins/filters/link_classifier.rb +26 -0
- data/plugins/filters/locale.yml +15 -0
- data/plugins/filters/main.rb +202 -0
- data/plugins/filters/markdown_nowiki.rb +15 -0
- data/plugins/filters/numbering.xsl +93 -0
- data/plugins/filters/orgmode.rb +6 -0
- data/plugins/filters/rubypants.rb +6 -0
- data/plugins/filters/s5/main.rb +32 -0
- data/plugins/filters/s5/s5.xsl +118 -0
- data/plugins/filters/tilt.rb +17 -0
- data/plugins/filters/toc.rb +50 -0
- data/plugins/filters/xhtml2latex.xsl +232 -0
- data/plugins/filters/xslt.rb +22 -0
- data/plugins/gallery/gallery.css +1 -0
- data/plugins/gallery/gallery.scss +28 -0
- data/plugins/gallery/main.rb +34 -0
- data/plugins/misc/fancybox/images/blank.gif +0 -0
- data/plugins/misc/fancybox/images/fancy_close.png +0 -0
- data/plugins/misc/fancybox/images/fancy_loading.png +0 -0
- data/plugins/misc/fancybox/images/fancy_nav_left.png +0 -0
- data/plugins/misc/fancybox/images/fancy_nav_right.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_e.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_n.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_ne.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_nw.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_s.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_se.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_sw.png +0 -0
- data/plugins/misc/fancybox/images/fancy_shadow_w.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_left.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_main.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_over.png +0 -0
- data/plugins/misc/fancybox/images/fancy_title_right.png +0 -0
- data/plugins/misc/fancybox/images/fancybox-x.png +0 -0
- data/plugins/misc/fancybox/images/fancybox-y.png +0 -0
- data/plugins/misc/fancybox/images/fancybox.png +0 -0
- data/plugins/misc/fancybox/jquery.fancybox.css +1 -0
- data/plugins/misc/fancybox/jquery.fancybox.scss +323 -0
- data/plugins/misc/fancybox/main.rb +4 -0
- data/plugins/misc/fancybox/script.js +37 -0
- data/plugins/misc/fancybox/script/00-jquery.mousewheel.js +84 -0
- data/plugins/misc/fancybox/script/01-jquery.easing.js +205 -0
- data/plugins/misc/fancybox/script/02-jquery.fancybox.js +1156 -0
- data/plugins/misc/fancybox/script/init.js +18 -0
- data/plugins/misc/system.rb +192 -0
- data/plugins/misc/variables.rb +29 -0
- data/plugins/misc/webdav.rb +45 -0
- data/plugins/repositories/git_grep.rb +69 -0
- data/plugins/repositories/gitrb_repository.rb +204 -0
- data/plugins/repositories/locale.yml +12 -0
- data/plugins/repositories/rugged_repository.rb +454 -0
- data/plugins/security/acl.rb +57 -0
- data/plugins/security/basic_auth.rb +21 -0
- data/plugins/security/locale.yml +21 -0
- data/plugins/security/persistent_login.rb +32 -0
- data/plugins/security/portal.rb +28 -0
- data/plugins/security/private_wiki.rb +24 -0
- data/plugins/security/readonly_wiki.rb +25 -0
- data/plugins/security/stack.rb +20 -0
- data/plugins/security/yamlfile.rb +66 -0
- data/plugins/tags/code.rb +6 -0
- data/plugins/tags/footnotes.rb +35 -0
- data/plugins/tags/gist-embed.css +123 -0
- data/plugins/tags/gist.rb +13 -0
- data/plugins/tags/html.rb +57 -0
- data/plugins/tags/include.rb +20 -0
- data/plugins/tags/main.rb +353 -0
- data/plugins/tags/math.rb +117 -0
- data/plugins/tags/scripting.rb +64 -0
- data/plugins/tags/sort.rb +7 -0
- data/plugins/tags/tabs.rb +20 -0
- data/plugins/treeview/images/collapsed.png +0 -0
- data/plugins/treeview/images/expanded.png +0 -0
- data/plugins/treeview/images/menu.png +0 -0
- data/plugins/treeview/images/tree.png +0 -0
- data/plugins/treeview/images/wait.gif +0 -0
- data/plugins/treeview/main.rb +16 -0
- data/plugins/treeview/script.js +5 -0
- data/plugins/treeview/script/00-jquery.treeview.js +164 -0
- data/plugins/treeview/script/init.js +25 -0
- data/plugins/treeview/treeview.css +1 -0
- data/plugins/treeview/treeview.scss +113 -0
- data/plugins/utils/assets.rb +74 -0
- data/plugins/utils/cache.rb +53 -0
- data/plugins/utils/image_magick.rb +34 -0
- data/plugins/utils/pygments.css +1 -0
- data/plugins/utils/pygments.rb +50 -0
- data/plugins/utils/pygments.scss +83 -0
- data/plugins/utils/semaphore.rb +50 -0
- data/plugins/utils/shell.rb +45 -0
- data/plugins/utils/store.rb +315 -0
- data/plugins/utils/worker.rb +36 -0
- data/plugins/utils/xml.rb +29 -0
- data/static/images/favicon.png +0 -0
- data/static/script.js +267 -0
- data/static/script/00-json2.js +486 -0
- data/static/script/01-jstorage.js +217 -0
- data/static/script/02-jquery.js +9440 -0
- data/static/script/03-jquery.ui.core.js +337 -0
- data/static/script/04-jquery.ui.widget.js +502 -0
- data/static/script/05-jquery.ui.position.js +517 -0
- data/static/script/06-jquery.ui.menu.js +609 -0
- data/static/script/07-jquery.ui.autocomplete.js +601 -0
- data/static/script/08-olelo.i18n.js +37 -0
- data/static/script/09-olelo.unsaved.js +68 -0
- data/static/script/10-olelo.historytable.js +40 -0
- data/static/script/11-olelo.pagination.js +18 -0
- data/static/script/13-olelo.tabwidget.js +57 -0
- data/static/script/14-olelo.timeago.js +70 -0
- data/static/script/15-olelo.underliner.js +31 -0
- data/static/script/16-olelo.ui.combobox.js +32 -0
- data/static/script/init.js +48 -0
- data/static/themes/atlantis/constants.scss +15 -0
- data/static/themes/atlantis/iehacks.scss +38 -0
- data/static/themes/atlantis/images/actions/delete.png +0 -0
- data/static/themes/atlantis/images/actions/edit.png +0 -0
- data/static/themes/atlantis/images/actions/history.png +0 -0
- data/static/themes/atlantis/images/actions/home.png +0 -0
- data/static/themes/atlantis/images/actions/move.png +0 -0
- data/static/themes/atlantis/images/actions/new.png +0 -0
- data/static/themes/atlantis/images/actions/page.png +0 -0
- data/static/themes/atlantis/images/bg/button.png +0 -0
- data/static/themes/atlantis/images/bg/container.png +0 -0
- data/static/themes/atlantis/images/bg/content.png +0 -0
- data/static/themes/atlantis/images/bg/footer.png +0 -0
- data/static/themes/atlantis/images/bg/header.jpg +0 -0
- data/static/themes/atlantis/images/bg/header.orig.jpg +0 -0
- data/static/themes/atlantis/images/bg/header_gray.jpg +0 -0
- data/static/themes/atlantis/images/bug.png +0 -0
- data/static/themes/atlantis/images/filetypes/7z.png +0 -0
- data/static/themes/atlantis/images/filetypes/_archive.png +0 -0
- data/static/themes/atlantis/images/filetypes/_audio.png +0 -0
- data/static/themes/atlantis/images/filetypes/_code.png +0 -0
- data/static/themes/atlantis/images/filetypes/_linux.png +0 -0
- data/static/themes/atlantis/images/filetypes/_picture.png +0 -0
- data/static/themes/atlantis/images/filetypes/_video.png +0 -0
- data/static/themes/atlantis/images/filetypes/bz2.png +0 -0
- data/static/themes/atlantis/images/filetypes/doc.png +0 -0
- data/static/themes/atlantis/images/filetypes/flac.png +0 -0
- data/static/themes/atlantis/images/filetypes/gz.png +0 -0
- data/static/themes/atlantis/images/filetypes/html.png +0 -0
- data/static/themes/atlantis/images/filetypes/java.png +0 -0
- data/static/themes/atlantis/images/filetypes/jpg.png +0 -0
- data/static/themes/atlantis/images/filetypes/midi.png +0 -0
- data/static/themes/atlantis/images/filetypes/mp3.png +0 -0
- data/static/themes/atlantis/images/filetypes/ogg.png +0 -0
- data/static/themes/atlantis/images/filetypes/pdf.png +0 -0
- data/static/themes/atlantis/images/filetypes/php.png +0 -0
- data/static/themes/atlantis/images/filetypes/png.png +0 -0
- data/static/themes/atlantis/images/filetypes/ppt.png +0 -0
- data/static/themes/atlantis/images/filetypes/psd.png +0 -0
- data/static/themes/atlantis/images/filetypes/rar.png +0 -0
- data/static/themes/atlantis/images/filetypes/rb.png +0 -0
- data/static/themes/atlantis/images/filetypes/sh.png +0 -0
- data/static/themes/atlantis/images/filetypes/tar.png +0 -0
- data/static/themes/atlantis/images/filetypes/txt.png +0 -0
- data/static/themes/atlantis/images/filetypes/wma.png +0 -0
- data/static/themes/atlantis/images/filetypes/xls.png +0 -0
- data/static/themes/atlantis/images/filetypes/zip.png +0 -0
- data/static/themes/atlantis/images/folder.png +0 -0
- data/static/themes/atlantis/images/folder_open.png +0 -0
- data/static/themes/atlantis/images/loading.gif +0 -0
- data/static/themes/atlantis/images/loading.xcf +0 -0
- data/static/themes/atlantis/images/not_found.png +0 -0
- data/static/themes/atlantis/images/page.png +0 -0
- data/static/themes/atlantis/images/search.png +0 -0
- data/static/themes/atlantis/layout.scss +115 -0
- data/static/themes/atlantis/menu.scss +99 -0
- data/static/themes/atlantis/print.scss +129 -0
- data/static/themes/atlantis/screen.scss +495 -0
- data/static/themes/atlantis/style.css +3 -0
- data/static/themes/lib/autocomplete.scss +39 -0
- data/static/themes/lib/headlines.scss +10 -0
- data/static/themes/lib/horizontal-list.scss +31 -0
- data/static/themes/lib/patch.scss +88 -0
- data/static/themes/lib/reset.scss +114 -0
- data/static/themes/lib/rounded.scss +46 -0
- data/static/themes/lib/shadow.scss +14 -0
- data/test/config_test.rb +28 -0
- data/test/factory_test.rb +29 -0
- data/test/hash_extensions_test.rb +16 -0
- data/test/helper.rb +38 -0
- data/test/hooks_test.rb +85 -0
- data/test/object_extensions_test.rb +20 -0
- data/test/page_test.rb +168 -0
- data/test/request_test.rb +166 -0
- data/test/string_extensions_test.rb +32 -0
- data/test/templates_test.rb +39 -0
- data/test/util_test.rb +71 -0
- data/views/changes.slim +22 -0
- data/views/compare.slim +8 -0
- data/views/delete.slim +9 -0
- data/views/deleted.slim +2 -0
- data/views/edit.slim +65 -0
- data/views/error.slim +6 -0
- data/views/history.slim +20 -0
- data/views/layout.slim +38 -0
- data/views/login.slim +37 -0
- data/views/move.slim +10 -0
- data/views/not_found.slim +6 -0
- data/views/profile.slim +26 -0
- data/views/show.slim +9 -0
- metadata +488 -0
@@ -0,0 +1,517 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery UI Position 1.9.0
|
3
|
+
* http://jqueryui.com
|
4
|
+
*
|
5
|
+
* Copyright 2012 jQuery Foundation and other contributors
|
6
|
+
* Released under the MIT license.
|
7
|
+
* http://jquery.org/license
|
8
|
+
*
|
9
|
+
* http://api.jqueryui.com/position/
|
10
|
+
*/
|
11
|
+
(function( $, undefined ) {
|
12
|
+
|
13
|
+
$.ui = $.ui || {};
|
14
|
+
|
15
|
+
var cachedScrollbarWidth,
|
16
|
+
max = Math.max,
|
17
|
+
abs = Math.abs,
|
18
|
+
round = Math.round,
|
19
|
+
rhorizontal = /left|center|right/,
|
20
|
+
rvertical = /top|center|bottom/,
|
21
|
+
roffset = /[\+\-]\d+%?/,
|
22
|
+
rposition = /^\w+/,
|
23
|
+
rpercent = /%$/,
|
24
|
+
_position = $.fn.position;
|
25
|
+
|
26
|
+
function getOffsets( offsets, width, height ) {
|
27
|
+
return [
|
28
|
+
parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
|
29
|
+
parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
|
30
|
+
];
|
31
|
+
}
|
32
|
+
function parseCss( element, property ) {
|
33
|
+
return parseInt( $.css( element, property ), 10 ) || 0;
|
34
|
+
}
|
35
|
+
|
36
|
+
$.position = {
|
37
|
+
scrollbarWidth: function() {
|
38
|
+
if ( cachedScrollbarWidth !== undefined ) {
|
39
|
+
return cachedScrollbarWidth;
|
40
|
+
}
|
41
|
+
var w1, w2,
|
42
|
+
div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
|
43
|
+
innerDiv = div.children()[0];
|
44
|
+
|
45
|
+
$( "body" ).append( div );
|
46
|
+
w1 = innerDiv.offsetWidth;
|
47
|
+
div.css( "overflow", "scroll" );
|
48
|
+
|
49
|
+
w2 = innerDiv.offsetWidth;
|
50
|
+
|
51
|
+
if ( w1 === w2 ) {
|
52
|
+
w2 = div[0].clientWidth;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.remove();
|
56
|
+
|
57
|
+
return (cachedScrollbarWidth = w1 - w2);
|
58
|
+
},
|
59
|
+
getScrollInfo: function( within ) {
|
60
|
+
var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
|
61
|
+
overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
|
62
|
+
hasOverflowX = overflowX === "scroll" ||
|
63
|
+
( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
|
64
|
+
hasOverflowY = overflowY === "scroll" ||
|
65
|
+
( overflowY === "auto" && within.height < within.element[0].scrollHeight );
|
66
|
+
return {
|
67
|
+
width: hasOverflowX ? $.position.scrollbarWidth() : 0,
|
68
|
+
height: hasOverflowY ? $.position.scrollbarWidth() : 0
|
69
|
+
};
|
70
|
+
},
|
71
|
+
getWithinInfo: function( element ) {
|
72
|
+
var withinElement = $( element || window ),
|
73
|
+
isWindow = $.isWindow( withinElement[0] );
|
74
|
+
return {
|
75
|
+
element: withinElement,
|
76
|
+
isWindow: isWindow,
|
77
|
+
offset: withinElement.offset() || { left: 0, top: 0 },
|
78
|
+
scrollLeft: withinElement.scrollLeft(),
|
79
|
+
scrollTop: withinElement.scrollTop(),
|
80
|
+
width: isWindow ? withinElement.width() : withinElement.outerWidth(),
|
81
|
+
height: isWindow ? withinElement.height() : withinElement.outerHeight()
|
82
|
+
};
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
$.fn.position = function( options ) {
|
87
|
+
if ( !options || !options.of ) {
|
88
|
+
return _position.apply( this, arguments );
|
89
|
+
}
|
90
|
+
|
91
|
+
// make a copy, we don't want to modify arguments
|
92
|
+
options = $.extend( {}, options );
|
93
|
+
|
94
|
+
var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
|
95
|
+
target = $( options.of ),
|
96
|
+
within = $.position.getWithinInfo( options.within ),
|
97
|
+
scrollInfo = $.position.getScrollInfo( within ),
|
98
|
+
targetElem = target[0],
|
99
|
+
collision = ( options.collision || "flip" ).split( " " ),
|
100
|
+
offsets = {};
|
101
|
+
|
102
|
+
if ( targetElem.nodeType === 9 ) {
|
103
|
+
targetWidth = target.width();
|
104
|
+
targetHeight = target.height();
|
105
|
+
targetOffset = { top: 0, left: 0 };
|
106
|
+
} else if ( $.isWindow( targetElem ) ) {
|
107
|
+
targetWidth = target.width();
|
108
|
+
targetHeight = target.height();
|
109
|
+
targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
|
110
|
+
} else if ( targetElem.preventDefault ) {
|
111
|
+
// force left top to allow flipping
|
112
|
+
options.at = "left top";
|
113
|
+
targetWidth = targetHeight = 0;
|
114
|
+
targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
|
115
|
+
} else {
|
116
|
+
targetWidth = target.outerWidth();
|
117
|
+
targetHeight = target.outerHeight();
|
118
|
+
targetOffset = target.offset();
|
119
|
+
}
|
120
|
+
// clone to reuse original targetOffset later
|
121
|
+
basePosition = $.extend( {}, targetOffset );
|
122
|
+
|
123
|
+
// force my and at to have valid horizontal and vertical positions
|
124
|
+
// if a value is missing or invalid, it will be converted to center
|
125
|
+
$.each( [ "my", "at" ], function() {
|
126
|
+
var pos = ( options[ this ] || "" ).split( " " ),
|
127
|
+
horizontalOffset,
|
128
|
+
verticalOffset;
|
129
|
+
|
130
|
+
if ( pos.length === 1) {
|
131
|
+
pos = rhorizontal.test( pos[ 0 ] ) ?
|
132
|
+
pos.concat( [ "center" ] ) :
|
133
|
+
rvertical.test( pos[ 0 ] ) ?
|
134
|
+
[ "center" ].concat( pos ) :
|
135
|
+
[ "center", "center" ];
|
136
|
+
}
|
137
|
+
pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
|
138
|
+
pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
|
139
|
+
|
140
|
+
// calculate offsets
|
141
|
+
horizontalOffset = roffset.exec( pos[ 0 ] );
|
142
|
+
verticalOffset = roffset.exec( pos[ 1 ] );
|
143
|
+
offsets[ this ] = [
|
144
|
+
horizontalOffset ? horizontalOffset[ 0 ] : 0,
|
145
|
+
verticalOffset ? verticalOffset[ 0 ] : 0
|
146
|
+
];
|
147
|
+
|
148
|
+
// reduce to just the positions without the offsets
|
149
|
+
options[ this ] = [
|
150
|
+
rposition.exec( pos[ 0 ] )[ 0 ],
|
151
|
+
rposition.exec( pos[ 1 ] )[ 0 ]
|
152
|
+
];
|
153
|
+
});
|
154
|
+
|
155
|
+
// normalize collision option
|
156
|
+
if ( collision.length === 1 ) {
|
157
|
+
collision[ 1 ] = collision[ 0 ];
|
158
|
+
}
|
159
|
+
|
160
|
+
if ( options.at[ 0 ] === "right" ) {
|
161
|
+
basePosition.left += targetWidth;
|
162
|
+
} else if ( options.at[ 0 ] === "center" ) {
|
163
|
+
basePosition.left += targetWidth / 2;
|
164
|
+
}
|
165
|
+
|
166
|
+
if ( options.at[ 1 ] === "bottom" ) {
|
167
|
+
basePosition.top += targetHeight;
|
168
|
+
} else if ( options.at[ 1 ] === "center" ) {
|
169
|
+
basePosition.top += targetHeight / 2;
|
170
|
+
}
|
171
|
+
|
172
|
+
atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
|
173
|
+
basePosition.left += atOffset[ 0 ];
|
174
|
+
basePosition.top += atOffset[ 1 ];
|
175
|
+
|
176
|
+
return this.each(function() {
|
177
|
+
var collisionPosition, using,
|
178
|
+
elem = $( this ),
|
179
|
+
elemWidth = elem.outerWidth(),
|
180
|
+
elemHeight = elem.outerHeight(),
|
181
|
+
marginLeft = parseCss( this, "marginLeft" ),
|
182
|
+
marginTop = parseCss( this, "marginTop" ),
|
183
|
+
collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
|
184
|
+
collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
|
185
|
+
position = $.extend( {}, basePosition ),
|
186
|
+
myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
|
187
|
+
|
188
|
+
if ( options.my[ 0 ] === "right" ) {
|
189
|
+
position.left -= elemWidth;
|
190
|
+
} else if ( options.my[ 0 ] === "center" ) {
|
191
|
+
position.left -= elemWidth / 2;
|
192
|
+
}
|
193
|
+
|
194
|
+
if ( options.my[ 1 ] === "bottom" ) {
|
195
|
+
position.top -= elemHeight;
|
196
|
+
} else if ( options.my[ 1 ] === "center" ) {
|
197
|
+
position.top -= elemHeight / 2;
|
198
|
+
}
|
199
|
+
|
200
|
+
position.left += myOffset[ 0 ];
|
201
|
+
position.top += myOffset[ 1 ];
|
202
|
+
|
203
|
+
// if the browser doesn't support fractions, then round for consistent results
|
204
|
+
if ( !$.support.offsetFractions ) {
|
205
|
+
position.left = round( position.left );
|
206
|
+
position.top = round( position.top );
|
207
|
+
}
|
208
|
+
|
209
|
+
collisionPosition = {
|
210
|
+
marginLeft: marginLeft,
|
211
|
+
marginTop: marginTop
|
212
|
+
};
|
213
|
+
|
214
|
+
$.each( [ "left", "top" ], function( i, dir ) {
|
215
|
+
if ( $.ui.position[ collision[ i ] ] ) {
|
216
|
+
$.ui.position[ collision[ i ] ][ dir ]( position, {
|
217
|
+
targetWidth: targetWidth,
|
218
|
+
targetHeight: targetHeight,
|
219
|
+
elemWidth: elemWidth,
|
220
|
+
elemHeight: elemHeight,
|
221
|
+
collisionPosition: collisionPosition,
|
222
|
+
collisionWidth: collisionWidth,
|
223
|
+
collisionHeight: collisionHeight,
|
224
|
+
offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
|
225
|
+
my: options.my,
|
226
|
+
at: options.at,
|
227
|
+
within: within,
|
228
|
+
elem : elem
|
229
|
+
});
|
230
|
+
}
|
231
|
+
});
|
232
|
+
|
233
|
+
if ( $.fn.bgiframe ) {
|
234
|
+
elem.bgiframe();
|
235
|
+
}
|
236
|
+
|
237
|
+
if ( options.using ) {
|
238
|
+
// adds feedback as second argument to using callback, if present
|
239
|
+
using = function( props ) {
|
240
|
+
var left = targetOffset.left - position.left,
|
241
|
+
right = left + targetWidth - elemWidth,
|
242
|
+
top = targetOffset.top - position.top,
|
243
|
+
bottom = top + targetHeight - elemHeight,
|
244
|
+
feedback = {
|
245
|
+
target: {
|
246
|
+
element: target,
|
247
|
+
left: targetOffset.left,
|
248
|
+
top: targetOffset.top,
|
249
|
+
width: targetWidth,
|
250
|
+
height: targetHeight
|
251
|
+
},
|
252
|
+
element: {
|
253
|
+
element: elem,
|
254
|
+
left: position.left,
|
255
|
+
top: position.top,
|
256
|
+
width: elemWidth,
|
257
|
+
height: elemHeight
|
258
|
+
},
|
259
|
+
horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
|
260
|
+
vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
|
261
|
+
};
|
262
|
+
if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
|
263
|
+
feedback.horizontal = "center";
|
264
|
+
}
|
265
|
+
if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
|
266
|
+
feedback.vertical = "middle";
|
267
|
+
}
|
268
|
+
if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
|
269
|
+
feedback.important = "horizontal";
|
270
|
+
} else {
|
271
|
+
feedback.important = "vertical";
|
272
|
+
}
|
273
|
+
options.using.call( this, props, feedback );
|
274
|
+
};
|
275
|
+
}
|
276
|
+
|
277
|
+
elem.offset( $.extend( position, { using: using } ) );
|
278
|
+
});
|
279
|
+
};
|
280
|
+
|
281
|
+
$.ui.position = {
|
282
|
+
fit: {
|
283
|
+
left: function( position, data ) {
|
284
|
+
var within = data.within,
|
285
|
+
withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
|
286
|
+
outerWidth = within.width,
|
287
|
+
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
|
288
|
+
overLeft = withinOffset - collisionPosLeft,
|
289
|
+
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
|
290
|
+
newOverRight;
|
291
|
+
|
292
|
+
// element is wider than within
|
293
|
+
if ( data.collisionWidth > outerWidth ) {
|
294
|
+
// element is initially over the left side of within
|
295
|
+
if ( overLeft > 0 && overRight <= 0 ) {
|
296
|
+
newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
|
297
|
+
position.left += overLeft - newOverRight;
|
298
|
+
// element is initially over right side of within
|
299
|
+
} else if ( overRight > 0 && overLeft <= 0 ) {
|
300
|
+
position.left = withinOffset;
|
301
|
+
// element is initially over both left and right sides of within
|
302
|
+
} else {
|
303
|
+
if ( overLeft > overRight ) {
|
304
|
+
position.left = withinOffset + outerWidth - data.collisionWidth;
|
305
|
+
} else {
|
306
|
+
position.left = withinOffset;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
// too far left -> align with left edge
|
310
|
+
} else if ( overLeft > 0 ) {
|
311
|
+
position.left += overLeft;
|
312
|
+
// too far right -> align with right edge
|
313
|
+
} else if ( overRight > 0 ) {
|
314
|
+
position.left -= overRight;
|
315
|
+
// adjust based on position and margin
|
316
|
+
} else {
|
317
|
+
position.left = max( position.left - collisionPosLeft, position.left );
|
318
|
+
}
|
319
|
+
},
|
320
|
+
top: function( position, data ) {
|
321
|
+
var within = data.within,
|
322
|
+
withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
|
323
|
+
outerHeight = data.within.height,
|
324
|
+
collisionPosTop = position.top - data.collisionPosition.marginTop,
|
325
|
+
overTop = withinOffset - collisionPosTop,
|
326
|
+
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
|
327
|
+
newOverBottom;
|
328
|
+
|
329
|
+
// element is taller than within
|
330
|
+
if ( data.collisionHeight > outerHeight ) {
|
331
|
+
// element is initially over the top of within
|
332
|
+
if ( overTop > 0 && overBottom <= 0 ) {
|
333
|
+
newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
|
334
|
+
position.top += overTop - newOverBottom;
|
335
|
+
// element is initially over bottom of within
|
336
|
+
} else if ( overBottom > 0 && overTop <= 0 ) {
|
337
|
+
position.top = withinOffset;
|
338
|
+
// element is initially over both top and bottom of within
|
339
|
+
} else {
|
340
|
+
if ( overTop > overBottom ) {
|
341
|
+
position.top = withinOffset + outerHeight - data.collisionHeight;
|
342
|
+
} else {
|
343
|
+
position.top = withinOffset;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
// too far up -> align with top
|
347
|
+
} else if ( overTop > 0 ) {
|
348
|
+
position.top += overTop;
|
349
|
+
// too far down -> align with bottom edge
|
350
|
+
} else if ( overBottom > 0 ) {
|
351
|
+
position.top -= overBottom;
|
352
|
+
// adjust based on position and margin
|
353
|
+
} else {
|
354
|
+
position.top = max( position.top - collisionPosTop, position.top );
|
355
|
+
}
|
356
|
+
}
|
357
|
+
},
|
358
|
+
flip: {
|
359
|
+
left: function( position, data ) {
|
360
|
+
var within = data.within,
|
361
|
+
withinOffset = within.offset.left + within.scrollLeft,
|
362
|
+
outerWidth = within.width,
|
363
|
+
offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
|
364
|
+
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
|
365
|
+
overLeft = collisionPosLeft - offsetLeft,
|
366
|
+
overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
|
367
|
+
myOffset = data.my[ 0 ] === "left" ?
|
368
|
+
-data.elemWidth :
|
369
|
+
data.my[ 0 ] === "right" ?
|
370
|
+
data.elemWidth :
|
371
|
+
0,
|
372
|
+
atOffset = data.at[ 0 ] === "left" ?
|
373
|
+
data.targetWidth :
|
374
|
+
data.at[ 0 ] === "right" ?
|
375
|
+
-data.targetWidth :
|
376
|
+
0,
|
377
|
+
offset = -2 * data.offset[ 0 ],
|
378
|
+
newOverRight,
|
379
|
+
newOverLeft;
|
380
|
+
|
381
|
+
if ( overLeft < 0 ) {
|
382
|
+
newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
|
383
|
+
if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
|
384
|
+
position.left += myOffset + atOffset + offset;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
else if ( overRight > 0 ) {
|
388
|
+
newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
|
389
|
+
if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
|
390
|
+
position.left += myOffset + atOffset + offset;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
},
|
394
|
+
top: function( position, data ) {
|
395
|
+
var within = data.within,
|
396
|
+
withinOffset = within.offset.top + within.scrollTop,
|
397
|
+
outerHeight = within.height,
|
398
|
+
offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
|
399
|
+
collisionPosTop = position.top - data.collisionPosition.marginTop,
|
400
|
+
overTop = collisionPosTop - offsetTop,
|
401
|
+
overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
|
402
|
+
top = data.my[ 1 ] === "top",
|
403
|
+
myOffset = top ?
|
404
|
+
-data.elemHeight :
|
405
|
+
data.my[ 1 ] === "bottom" ?
|
406
|
+
data.elemHeight :
|
407
|
+
0,
|
408
|
+
atOffset = data.at[ 1 ] === "top" ?
|
409
|
+
data.targetHeight :
|
410
|
+
data.at[ 1 ] === "bottom" ?
|
411
|
+
-data.targetHeight :
|
412
|
+
0,
|
413
|
+
offset = -2 * data.offset[ 1 ],
|
414
|
+
newOverTop,
|
415
|
+
newOverBottom;
|
416
|
+
if ( overTop < 0 ) {
|
417
|
+
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
|
418
|
+
if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
|
419
|
+
position.top += myOffset + atOffset + offset;
|
420
|
+
}
|
421
|
+
}
|
422
|
+
else if ( overBottom > 0 ) {
|
423
|
+
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
|
424
|
+
if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
|
425
|
+
position.top += myOffset + atOffset + offset;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
}
|
429
|
+
},
|
430
|
+
flipfit: {
|
431
|
+
left: function() {
|
432
|
+
$.ui.position.flip.left.apply( this, arguments );
|
433
|
+
$.ui.position.fit.left.apply( this, arguments );
|
434
|
+
},
|
435
|
+
top: function() {
|
436
|
+
$.ui.position.flip.top.apply( this, arguments );
|
437
|
+
$.ui.position.fit.top.apply( this, arguments );
|
438
|
+
}
|
439
|
+
}
|
440
|
+
};
|
441
|
+
|
442
|
+
// fraction support test
|
443
|
+
(function () {
|
444
|
+
var testElement, testElementParent, testElementStyle, offsetLeft, i,
|
445
|
+
body = document.getElementsByTagName( "body" )[ 0 ],
|
446
|
+
div = document.createElement( "div" );
|
447
|
+
|
448
|
+
//Create a "fake body" for testing based on method used in jQuery.support
|
449
|
+
testElement = document.createElement( body ? "div" : "body" );
|
450
|
+
testElementStyle = {
|
451
|
+
visibility: "hidden",
|
452
|
+
width: 0,
|
453
|
+
height: 0,
|
454
|
+
border: 0,
|
455
|
+
margin: 0,
|
456
|
+
background: "none"
|
457
|
+
};
|
458
|
+
if ( body ) {
|
459
|
+
$.extend( testElementStyle, {
|
460
|
+
position: "absolute",
|
461
|
+
left: "-1000px",
|
462
|
+
top: "-1000px"
|
463
|
+
});
|
464
|
+
}
|
465
|
+
for ( i in testElementStyle ) {
|
466
|
+
testElement.style[ i ] = testElementStyle[ i ];
|
467
|
+
}
|
468
|
+
testElement.appendChild( div );
|
469
|
+
testElementParent = body || document.documentElement;
|
470
|
+
testElementParent.insertBefore( testElement, testElementParent.firstChild );
|
471
|
+
|
472
|
+
div.style.cssText = "position: absolute; left: 10.7432222px;";
|
473
|
+
|
474
|
+
offsetLeft = $( div ).offset().left;
|
475
|
+
$.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
|
476
|
+
|
477
|
+
testElement.innerHTML = "";
|
478
|
+
testElementParent.removeChild( testElement );
|
479
|
+
})();
|
480
|
+
|
481
|
+
// DEPRECATED
|
482
|
+
if ( $.uiBackCompat !== false ) {
|
483
|
+
// offset option
|
484
|
+
(function( $ ) {
|
485
|
+
var _position = $.fn.position;
|
486
|
+
$.fn.position = function( options ) {
|
487
|
+
if ( !options || !options.offset ) {
|
488
|
+
return _position.call( this, options );
|
489
|
+
}
|
490
|
+
var offset = options.offset.split( " " ),
|
491
|
+
at = options.at.split( " " );
|
492
|
+
if ( offset.length === 1 ) {
|
493
|
+
offset[ 1 ] = offset[ 0 ];
|
494
|
+
}
|
495
|
+
if ( /^\d/.test( offset[ 0 ] ) ) {
|
496
|
+
offset[ 0 ] = "+" + offset[ 0 ];
|
497
|
+
}
|
498
|
+
if ( /^\d/.test( offset[ 1 ] ) ) {
|
499
|
+
offset[ 1 ] = "+" + offset[ 1 ];
|
500
|
+
}
|
501
|
+
if ( at.length === 1 ) {
|
502
|
+
if ( /left|center|right/.test( at[ 0 ] ) ) {
|
503
|
+
at[ 1 ] = "center";
|
504
|
+
} else {
|
505
|
+
at[ 1 ] = at[ 0 ];
|
506
|
+
at[ 0 ] = "center";
|
507
|
+
}
|
508
|
+
}
|
509
|
+
return _position.call( this, $.extend( options, {
|
510
|
+
at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
|
511
|
+
offset: undefined
|
512
|
+
} ) );
|
513
|
+
};
|
514
|
+
}( jQuery ) );
|
515
|
+
}
|
516
|
+
|
517
|
+
}( jQuery ) );
|