ui_alchemy-rails 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +6 -0
- data/Rakefile +21 -0
- data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.eot +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.svg +154 -0
- data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.ttf +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Bold-webfont.woff +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.eot +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.svg +154 -0
- data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.ttf +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-BoldItalic-webfont.woff +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.eot +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.svg +154 -0
- data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.ttf +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Italic-webfont.woff +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.eot +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.svg +154 -0
- data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.ttf +0 -0
- data/app/assets/fonts/alchemy/LiberationSans-Regular-webfont.woff +0 -0
- data/app/assets/fonts/alchemy/Red Hat Liberation License.txt +78 -0
- data/app/assets/fonts/alchemy/overpass_bold-web.eot +0 -0
- data/app/assets/fonts/alchemy/overpass_bold-web.svg +470 -0
- data/app/assets/fonts/alchemy/overpass_bold-web.ttf +0 -0
- data/app/assets/fonts/alchemy/overpass_bold-web.woff +0 -0
- data/app/assets/fonts/alchemy/overpass_regular-web.eot +0 -0
- data/app/assets/fonts/alchemy/overpass_regular-web.svg +470 -0
- data/app/assets/fonts/alchemy/overpass_regular-web.ttf +0 -0
- data/app/assets/fonts/alchemy/overpass_regular-web.woff +0 -0
- data/app/assets/images/alchemy/icons/action-icons.png +0 -0
- data/app/assets/images/alchemy/icons/arrow_icon.png +0 -0
- data/app/assets/images/alchemy/icons/chosen-sprite.png +0 -0
- data/app/assets/images/alchemy/icons/error_icon.png +0 -0
- data/app/assets/images/alchemy/icons/objects.png +0 -0
- data/app/assets/images/alchemy/icons/spinner.gif +0 -0
- data/app/assets/images/alchemy/icons/spinner_head.gif +0 -0
- data/app/assets/images/alchemy/icons/success_icon.png +0 -0
- data/app/assets/images/alchemy/icons/warning_icon.png +0 -0
- data/app/assets/javascripts/alchemy/flash_messages.js +12 -0
- data/app/assets/javascripts/alchemy/forms.js +25 -0
- data/app/assets/javascripts/alchemy/i18n.js +36 -0
- data/app/assets/javascripts/alchemy/login.js +130 -0
- data/app/assets/javascripts/alchemy/password.js +99 -0
- data/app/assets/stylesheets/alchemy/components/_chosen.scss +423 -0
- data/app/assets/stylesheets/alchemy/components/_content.scss +58 -0
- data/app/assets/stylesheets/alchemy/components/_helpers.scss +38 -0
- data/app/assets/stylesheets/alchemy/components/_media.scss +49 -0
- data/app/assets/stylesheets/alchemy/components/_media_object.scss +22 -0
- data/app/assets/stylesheets/alchemy/components/_normalize.scss +396 -0
- data/app/assets/stylesheets/alchemy/components/_shared.scss +18 -0
- data/app/assets/stylesheets/alchemy/components/buttons/_buttons.scss +278 -0
- data/app/assets/stylesheets/alchemy/components/buttons/_buttons_vars.scss +11 -0
- data/app/assets/stylesheets/alchemy/components/flash_messages/_flash_messages.scss +93 -0
- data/app/assets/stylesheets/alchemy/components/flash_messages/_flash_messages_vars.scss +3 -0
- data/app/assets/stylesheets/alchemy/components/fonts/_liberation.scss +44 -0
- data/app/assets/stylesheets/alchemy/components/fonts/_overpass.scss +24 -0
- data/app/assets/stylesheets/alchemy/components/footer/_footer.scss +53 -0
- data/app/assets/stylesheets/alchemy/components/footer/_footer_vars.scss +4 -0
- data/app/assets/stylesheets/alchemy/components/forms/_forms.scss +552 -0
- data/app/assets/stylesheets/alchemy/components/forms/_forms_ie.scss +45 -0
- data/app/assets/stylesheets/alchemy/components/forms/_forms_mixins.scss +18 -0
- data/app/assets/stylesheets/alchemy/components/forms/_forms_responsive.scss +167 -0
- data/app/assets/stylesheets/alchemy/components/forms/_forms_vars.scss +25 -0
- data/app/assets/stylesheets/alchemy/components/header/_header.scss +216 -0
- data/app/assets/stylesheets/alchemy/components/header/_header_vars.scss +11 -0
- data/app/assets/stylesheets/alchemy/components/login/_login.scss +173 -0
- data/app/assets/stylesheets/alchemy/components/login/_login_mixins.scss +7 -0
- data/app/assets/stylesheets/alchemy/components/login/_login_vars.scss +19 -0
- data/app/assets/stylesheets/alchemy/components/sprites/_sprites.scss +110 -0
- data/app/assets/stylesheets/alchemy/components/sprites/_sprites_mixins.scss +9 -0
- data/app/assets/stylesheets/alchemy/components/text/_text.scss +30 -0
- data/app/assets/stylesheets/alchemy/components/text/_text_vars.scss +1 -0
- data/app/assets/stylesheets/alchemy/composites/content_elements.scss +6 -0
- data/app/assets/stylesheets/alchemy/composites/login.scss +9 -0
- data/app/assets/stylesheets/alchemy/composites/shell.scss +4 -0
- data/app/assets/stylesheets/alchemy/partials/_base.scss +8 -0
- data/app/assets/stylesheets/alchemy/partials/_colors.scss +99 -0
- data/app/assets/stylesheets/alchemy/partials/_mixins.scss +24 -0
- data/app/assets/stylesheets/alchemy/partials/_vars.scss +31 -0
- data/app/helpers/ui_alchemy/gettext_translations.rb +28 -0
- data/app/helpers/ui_alchemy/layout_helper.rb +35 -0
- data/app/helpers/ui_alchemy/rails_translations.rb +21 -0
- data/app/helpers/ui_alchemy/translation_helper.rb +19 -0
- data/app/views/alchemy/layouts/_change_password_layout.html.haml +20 -0
- data/app/views/alchemy/layouts/_common_i18n.haml +4 -0
- data/app/views/alchemy/layouts/_header_layout.haml +13 -0
- data/app/views/alchemy/layouts/_login_layout.html.haml +58 -0
- data/app/views/alchemy/layouts/_user_session_layout.haml +17 -0
- data/app/views/alchemy/layouts/base.html.haml +20 -0
- data/app/views/alchemy/layouts/shell_layout.haml +10 -0
- data/lib/ui_alchemy/rails/engine.rb +6 -0
- data/lib/ui_alchemy/rails/version.rb +5 -0
- data/lib/ui_alchemy-rails.rb +2 -0
- data/vendor/assets/javascripts/alchemy/handlebars.js +2201 -0
- data/vendor/assets/javascripts/alchemy/html5shiv.js +298 -0
- data/vendor/assets/javascripts/alchemy/jquery/jquery-1.6.2.js +8981 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/chosen.jquery.js +1003 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/excanvas.js +1427 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/excanvas.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.colorhelpers.js +179 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.colorhelpers.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.crosshair.js +167 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.crosshair.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.fillbetween.js +183 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.fillbetween.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.image.js +238 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.image.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.js +2599 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.min.js +6 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.navigate.js +336 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.navigate.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.pie.js +750 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.pie.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.resize.js +60 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.resize.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.selection.js +344 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.selection.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.stack.js +184 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.stack.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.symbol.js +70 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.symbol.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.threshold.js +103 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/flot-0.7/jquery.flot.threshold.min.js +1 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/blank.svg +3 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/custom_test.js +67 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.css +9 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.js +1101 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.min.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svg.pack.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.js +396 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.min.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svgfilter.pack.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.js +1337 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.min.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/jquery.svggraph.pack.js +7 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/lion.svg +161 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery-svg/test.js +714 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ajaxfileupload.js +205 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ba-bbq.js +1137 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ba-resize.js +246 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.cookie.js +92 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.fancyqueries.js +106 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.flash.js +288 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.form.js +964 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.hoverIntent.js +106 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jeditable.ajaxupload.js +62 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jeditable.js +556 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jnotify.js +210 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jscrollpane.js +1390 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.jscrollpane.min.js +11 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.linkHover.js +89 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.loadmask.min.js +10 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.mousewheel.js +78 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.multiselect.filter.js +176 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.multiselect.js +668 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.pack.js +11 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.periodicalupdater.js +175 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.sortElements.js +75 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.sparkline.min.js +94 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.text-overflow.js +60 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.timepickr.js +214 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.timers.js +142 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.tipsy.js +358 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.treeTable.js +226 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.trunk8.js +203 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ui.multiselect.js +338 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.ui.totop.js +58 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/jquery.uitablefilter.js +95 -0
- data/vendor/assets/javascripts/alchemy/jquery/plugins/ui.spinner.js +683 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_75_dadada_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_75_e6e6e6_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-hard_95_ffffff_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_highlight-soft_80_e0e0e0_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_inset-hard_65_ffffff_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_8f8f8f_256x240.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_97baed_256x240.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/css/custom-theme/jquery-ui-1.8.11.custom.css +573 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/js/jquery-1.5.1.min.js +16 -0
- data/vendor/assets/javascripts/alchemy/jquery-ui-1.8.11.custom/js/jquery-ui-1.8.11.custom.min.js +783 -0
- data/vendor/assets/javascripts/alchemy/rails.js +331 -0
- data/vendor/assets/javascripts/alchemy/underscore-1.3.1.js +999 -0
- metadata +252 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery treeTable Plugin unreleased
|
3
|
+
* http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/
|
4
|
+
*
|
5
|
+
* Copyright 2011, Ludo van den Boom
|
6
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
+
*/
|
8
|
+
(function($) {
|
9
|
+
// Helps to make options available to all functions
|
10
|
+
// TODO: This gives problems when there are both expandable and non-expandable
|
11
|
+
// trees on a page. The options shouldn't be global to all these instances!
|
12
|
+
var options;
|
13
|
+
var defaultPaddingLeft;
|
14
|
+
|
15
|
+
$.fn.treeTable = function(opts) {
|
16
|
+
options = $.extend({}, $.fn.treeTable.defaults, opts);
|
17
|
+
|
18
|
+
return this.each(function() {
|
19
|
+
$(this).addClass("treeTable").find("tbody tr").each(function() {
|
20
|
+
// Initialize root nodes only if possible
|
21
|
+
if(!options.expandable || $(this)[0].className.search(options.childPrefix) == -1) {
|
22
|
+
// To optimize performance of indentation, I retrieve the padding-left
|
23
|
+
// value of the first root node. This way I only have to call +css+
|
24
|
+
// once.
|
25
|
+
if (isNaN(defaultPaddingLeft)) {
|
26
|
+
defaultPaddingLeft = parseInt($($(this).children("td")[options.treeColumn]).css('padding-left'), 10);
|
27
|
+
}
|
28
|
+
|
29
|
+
initialize($(this));
|
30
|
+
} else if(options.initialState == "collapsed") {
|
31
|
+
this.style.display = "none"; // Performance! $(this).hide() is slow...
|
32
|
+
}
|
33
|
+
});
|
34
|
+
});
|
35
|
+
};
|
36
|
+
|
37
|
+
$.fn.treeTable.defaults = {
|
38
|
+
childPrefix: "child-of-",
|
39
|
+
clickableNodeNames: false,
|
40
|
+
expandable: true,
|
41
|
+
indent: 19,
|
42
|
+
initialState: "collapsed",
|
43
|
+
onNodeShow: null,
|
44
|
+
treeColumn: 0
|
45
|
+
};
|
46
|
+
|
47
|
+
// Recursively hide all node's children in a tree
|
48
|
+
$.fn.collapse = function() {
|
49
|
+
$(this).addClass("collapsed");
|
50
|
+
|
51
|
+
childrenOf($(this)).each(function() {
|
52
|
+
if(!$(this).hasClass("collapsed")) {
|
53
|
+
$(this).collapse();
|
54
|
+
}
|
55
|
+
|
56
|
+
this.style.display = "none"; // Performance! $(this).hide() is slow...
|
57
|
+
});
|
58
|
+
|
59
|
+
return this;
|
60
|
+
};
|
61
|
+
|
62
|
+
// Recursively show all node's children in a tree
|
63
|
+
$.fn.expand = function() {
|
64
|
+
$(this).removeClass("collapsed").addClass("expanded");
|
65
|
+
|
66
|
+
childrenOf($(this)).each(function() {
|
67
|
+
initialize($(this));
|
68
|
+
|
69
|
+
if($(this).is(".expanded.parent")) {
|
70
|
+
$(this).expand();
|
71
|
+
}
|
72
|
+
|
73
|
+
// this.style.display = "table-row"; // Unfortunately this is not possible with IE :-(
|
74
|
+
$(this).show();
|
75
|
+
|
76
|
+
if($.isFunction(options.onNodeShow)) {
|
77
|
+
options.onNodeShow.call();
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
return this;
|
82
|
+
};
|
83
|
+
|
84
|
+
// Reveal a node by expanding all ancestors
|
85
|
+
$.fn.reveal = function() {
|
86
|
+
$(ancestorsOf($(this)).reverse()).each(function() {
|
87
|
+
initialize($(this));
|
88
|
+
$(this).expand().show();
|
89
|
+
});
|
90
|
+
|
91
|
+
return this;
|
92
|
+
};
|
93
|
+
|
94
|
+
// Add an entire branch to +destination+
|
95
|
+
$.fn.appendBranchTo = function(destination) {
|
96
|
+
var node = $(this);
|
97
|
+
var parent = parentOf(node);
|
98
|
+
|
99
|
+
var ancestorNames = $.map(ancestorsOf($(destination)), function(a) { return a.id; });
|
100
|
+
|
101
|
+
// Conditions:
|
102
|
+
// 1: +node+ should not be inserted in a location in a branch if this would
|
103
|
+
// result in +node+ being an ancestor of itself.
|
104
|
+
// 2: +node+ should not have a parent OR the destination should not be the
|
105
|
+
// same as +node+'s current parent (this last condition prevents +node+
|
106
|
+
// from being moved to the same location where it already is).
|
107
|
+
// 3: +node+ should not be inserted as a child of +node+ itself.
|
108
|
+
if($.inArray(node[0].id, ancestorNames) == -1 && (!parent || (destination.id != parent[0].id)) && destination.id != node[0].id) {
|
109
|
+
indent(node, ancestorsOf(node).length * options.indent * -1); // Remove indentation
|
110
|
+
|
111
|
+
if(parent) { node.removeClass(options.childPrefix + parent[0].id); }
|
112
|
+
|
113
|
+
node.addClass(options.childPrefix + destination.id);
|
114
|
+
move(node, destination); // Recursively move nodes to new location
|
115
|
+
indent(node, ancestorsOf(node).length * options.indent);
|
116
|
+
}
|
117
|
+
|
118
|
+
return this;
|
119
|
+
};
|
120
|
+
|
121
|
+
// Add reverse() function from JS Arrays
|
122
|
+
$.fn.reverse = function() {
|
123
|
+
return this.pushStack(this.get().reverse(), arguments);
|
124
|
+
};
|
125
|
+
|
126
|
+
// Toggle an entire branch
|
127
|
+
$.fn.toggleBranch = function() {
|
128
|
+
if($(this).hasClass("collapsed")) {
|
129
|
+
$(this).expand();
|
130
|
+
} else {
|
131
|
+
$(this).removeClass("expanded").collapse();
|
132
|
+
}
|
133
|
+
|
134
|
+
return this;
|
135
|
+
};
|
136
|
+
|
137
|
+
// === Private functions
|
138
|
+
|
139
|
+
function ancestorsOf(node) {
|
140
|
+
var ancestors = [];
|
141
|
+
while(node = parentOf(node)) {
|
142
|
+
ancestors[ancestors.length] = node[0];
|
143
|
+
}
|
144
|
+
return ancestors;
|
145
|
+
};
|
146
|
+
|
147
|
+
function childrenOf(node) {
|
148
|
+
return $("table.treeTable tbody tr." + options.childPrefix + node[0].id);
|
149
|
+
};
|
150
|
+
|
151
|
+
function getPaddingLeft(node) {
|
152
|
+
var paddingLeft = parseInt(node[0].style.paddingLeft, 10);
|
153
|
+
return (isNaN(paddingLeft)) ? defaultPaddingLeft : paddingLeft;
|
154
|
+
}
|
155
|
+
|
156
|
+
function indent(node, value) {
|
157
|
+
var cell = $(node.children("td")[options.treeColumn]);
|
158
|
+
cell[0].style.paddingLeft = getPaddingLeft(cell) + value + "px";
|
159
|
+
|
160
|
+
childrenOf(node).each(function() {
|
161
|
+
indent($(this), value);
|
162
|
+
});
|
163
|
+
};
|
164
|
+
|
165
|
+
function initialize(node) {
|
166
|
+
if(!node.hasClass("initialized")) {
|
167
|
+
node.addClass("initialized");
|
168
|
+
|
169
|
+
var childNodes = childrenOf(node);
|
170
|
+
|
171
|
+
if(!node.hasClass("parent") && childNodes.length > 0) {
|
172
|
+
node.addClass("parent");
|
173
|
+
}
|
174
|
+
|
175
|
+
if(node.hasClass("parent")) {
|
176
|
+
var cell = $(node.children("td")[options.treeColumn]);
|
177
|
+
var padding = getPaddingLeft(cell) + options.indent;
|
178
|
+
|
179
|
+
childNodes.each(function() {
|
180
|
+
$(this).children("td")[options.treeColumn].style.paddingLeft = padding + "px";
|
181
|
+
});
|
182
|
+
|
183
|
+
if(options.expandable) {
|
184
|
+
cell.prepend('<span style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></span>');
|
185
|
+
$(cell[0].firstChild).click(function() { node.toggleBranch(); });
|
186
|
+
|
187
|
+
if(options.clickableNodeNames) {
|
188
|
+
cell[0].style.cursor = "pointer";
|
189
|
+
$(cell).click(function(e) {
|
190
|
+
// Don't double-toggle if the click is on the existing expander icon
|
191
|
+
if (e.target.className != 'expander') {
|
192
|
+
node.toggleBranch();
|
193
|
+
}
|
194
|
+
});
|
195
|
+
}
|
196
|
+
|
197
|
+
// Check for a class set explicitly by the user, otherwise set the default class
|
198
|
+
if(!(node.hasClass("expanded") || node.hasClass("collapsed"))) {
|
199
|
+
node.addClass(options.initialState);
|
200
|
+
}
|
201
|
+
|
202
|
+
if(node.hasClass("expanded")) {
|
203
|
+
node.expand();
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
};
|
209
|
+
|
210
|
+
function move(node, destination) {
|
211
|
+
node.insertAfter(destination);
|
212
|
+
childrenOf(node).reverse().each(function() { move($(this), node[0]); });
|
213
|
+
};
|
214
|
+
|
215
|
+
function parentOf(node) {
|
216
|
+
var classNames = node[0].className.split(' ');
|
217
|
+
|
218
|
+
for(var key=0; key<classNames.length; key++) {
|
219
|
+
if(classNames[key].match(options.childPrefix)) {
|
220
|
+
return $("#" + classNames[key].substring(9));
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
return null;
|
225
|
+
};
|
226
|
+
})(jQuery);
|
@@ -0,0 +1,203 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012 Rick Viscomi (rviscomi@gmail.com)
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
*
|
6
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
*
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
(function ($) {
|
13
|
+
var methods,
|
14
|
+
utils,
|
15
|
+
SIDES = {
|
16
|
+
/* cen...ter */
|
17
|
+
center: 'center',
|
18
|
+
/* ...left */
|
19
|
+
left: 'left',
|
20
|
+
/* right... */
|
21
|
+
right: 'right'
|
22
|
+
},
|
23
|
+
WIDTH = {
|
24
|
+
auto: 'auto'
|
25
|
+
},
|
26
|
+
settings = {
|
27
|
+
fill: '…',
|
28
|
+
lines: 1,
|
29
|
+
side: SIDES.right,
|
30
|
+
tooltip: true,
|
31
|
+
width: WIDTH.auto
|
32
|
+
};
|
33
|
+
|
34
|
+
function truncate() {
|
35
|
+
var width = settings.width,
|
36
|
+
side = settings.side,
|
37
|
+
fill = settings.fill,
|
38
|
+
line_height = parseInt(this.css('line-height')) * settings.lines,
|
39
|
+
str = this.attr('title') || this.text(),
|
40
|
+
length = str.length,
|
41
|
+
i = 1,
|
42
|
+
max_bite = '',
|
43
|
+
bite_size,
|
44
|
+
bite;
|
45
|
+
|
46
|
+
/* Reset the field to the original string. */
|
47
|
+
this.html(str);
|
48
|
+
|
49
|
+
if (width === WIDTH.auto) {
|
50
|
+
/* Assuming there is no "overflow: hidden". */
|
51
|
+
if (this.height() <= line_height) {
|
52
|
+
/* Text is already at the optimal trunkage. */
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
/* Binary search technique for finding the optimal trunkage. */
|
57
|
+
/* Find the maximum bite without overflowing. */
|
58
|
+
bite_size = length >> i; // Halve the length.
|
59
|
+
|
60
|
+
do {
|
61
|
+
bite = utils.eatStr(str, side, bite_size, fill);
|
62
|
+
|
63
|
+
this.html(bite);
|
64
|
+
|
65
|
+
i++;
|
66
|
+
|
67
|
+
if (this.height() > line_height) {
|
68
|
+
bite_size += length >> i; // Length divided by 2**i
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
bite_size -= length >> i; // Length divided by 2**i
|
72
|
+
|
73
|
+
/* Save the bigger bite. */
|
74
|
+
max_bite = (max_bite.length > bite.length) ? max_bite : bite;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
while (length >> i > 0);
|
78
|
+
|
79
|
+
/* Display the biggest bite. */
|
80
|
+
this.html(max_bite);
|
81
|
+
|
82
|
+
if (settings.tooltip) {
|
83
|
+
this.attr('title', str);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
else if (!isNaN(width)) {
|
87
|
+
bite_size = width;
|
88
|
+
|
89
|
+
bite = utils.eatStr(str, side, bite_size, fill);
|
90
|
+
|
91
|
+
this.html(bite);
|
92
|
+
|
93
|
+
if (settings.tooltip) {
|
94
|
+
this.attr('title', str);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
$.error('Invalid width "' + width + '".');
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
methods = {
|
103
|
+
init: function (options) {
|
104
|
+
settings = $.extend(settings, options);
|
105
|
+
|
106
|
+
return this.each(function () {
|
107
|
+
truncate.call($(this));
|
108
|
+
});
|
109
|
+
},
|
110
|
+
|
111
|
+
/** Updates the text value of the elements while maintaining truncation. */
|
112
|
+
update: function (text) {
|
113
|
+
return this.each(function () {
|
114
|
+
/* Update text. */
|
115
|
+
if (text) {
|
116
|
+
this.text(text);
|
117
|
+
}
|
118
|
+
|
119
|
+
/* Truncate accordingly. */
|
120
|
+
truncate.call($(this));
|
121
|
+
});
|
122
|
+
},
|
123
|
+
|
124
|
+
/** Returns this instance's settings object. NOT CHAINABLE. */
|
125
|
+
getSettings: function () {
|
126
|
+
return settings;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
|
130
|
+
utils = {
|
131
|
+
/** Replaces [bite_size] [side]-most chars in [str] with [fill]. */
|
132
|
+
eatStr: function (str, side, bite_size, fill) {
|
133
|
+
var length = str.length,
|
134
|
+
key = utils.eatStr.generateKey.apply(null, arguments),
|
135
|
+
half_length,
|
136
|
+
half_bite_size;
|
137
|
+
|
138
|
+
/* If the result is already in the cache, return it. */
|
139
|
+
if (utils.eatStr.cache[key]) {
|
140
|
+
return utils.eatStr.cache[key];
|
141
|
+
}
|
142
|
+
|
143
|
+
/* Common error handling. */
|
144
|
+
if ((typeof str !== 'string') || (length === 0)) {
|
145
|
+
$.error('Invalid source string "' + str + '".');
|
146
|
+
}
|
147
|
+
if ((bite_size < 0) || (bite_size > length)) {
|
148
|
+
$.error('Invalid bite size "' + bite_size + '".');
|
149
|
+
}
|
150
|
+
else if (bite_size === 0) {
|
151
|
+
/* No bite should show no truncation. */
|
152
|
+
return str;
|
153
|
+
}
|
154
|
+
if (typeof (fill + '') !== 'string') {
|
155
|
+
$.error('Fill unable to be converted to a string.');
|
156
|
+
}
|
157
|
+
|
158
|
+
/* Compute the result, store it in the cache, and return it. */
|
159
|
+
switch (side) {
|
160
|
+
case SIDES.right:
|
161
|
+
/* str... */
|
162
|
+
return utils.eatStr.cache[key] =
|
163
|
+
$.trim(str.substr(0, length - bite_size)) + fill;
|
164
|
+
|
165
|
+
case SIDES.left:
|
166
|
+
/* ...str */
|
167
|
+
return utils.eatStr.cache[key] =
|
168
|
+
fill + $.trim(str.substr(bite_size));
|
169
|
+
|
170
|
+
case SIDES.center:
|
171
|
+
/* Bit-shift to the right by one === Math.floor(x / 2) */
|
172
|
+
half_length = length >> 1; // halve the length
|
173
|
+
half_bite_size = bite_size >> 1; // halve the bite_size
|
174
|
+
|
175
|
+
/* st...r */
|
176
|
+
return utils.eatStr.cache[key] =
|
177
|
+
$.trim(utils.eatStr(str.substr(0, length - half_length), SIDES.right, bite_size - half_bite_size, '')) +
|
178
|
+
fill +
|
179
|
+
$.trim(utils.eatStr(str.substr(length - half_length), SIDES.left, half_bite_size, ''));
|
180
|
+
|
181
|
+
default:
|
182
|
+
$.error('Invalid side "' + side + '".');
|
183
|
+
}
|
184
|
+
}
|
185
|
+
};
|
186
|
+
|
187
|
+
utils.eatStr.cache = {};
|
188
|
+
utils.eatStr.generateKey = function () {
|
189
|
+
return Array.prototype.join.call(arguments, '');
|
190
|
+
};
|
191
|
+
|
192
|
+
$.fn.trunk8 = function (method) {
|
193
|
+
if (methods[method]) {
|
194
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
195
|
+
}
|
196
|
+
else if (typeof method === 'object' || !method) {
|
197
|
+
return methods.init.apply(this, arguments);
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
$.error('Method ' + method + ' does not exist on jQuery.trunk8');
|
201
|
+
}
|
202
|
+
};
|
203
|
+
})(jQuery);
|