stuff_to_do_plugin 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYRIGHT.txt +18 -0
- data/CREDITS.txt +6 -0
- data/GPL.txt +339 -0
- data/README.rdoc +61 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/app/controllers/stuff_to_do_controller.rb +161 -0
- data/app/helpers/stuff_to_do_helper.rb +88 -0
- data/app/models/stuff_to_do.rb +208 -0
- data/app/models/stuff_to_do_filter.rb +32 -0
- data/app/models/stuff_to_do_mailer.rb +16 -0
- data/app/views/settings/_stuff_to_do_settings.html.erb +27 -0
- data/app/views/stuff_to_do/_issue.html.erb +16 -0
- data/app/views/stuff_to_do/_item.html.erb +5 -0
- data/app/views/stuff_to_do/_left_panes.html.erb +51 -0
- data/app/views/stuff_to_do/_panes.html.erb +11 -0
- data/app/views/stuff_to_do/_project.html.erb +6 -0
- data/app/views/stuff_to_do/_right_panes.html.erb +25 -0
- data/app/views/stuff_to_do/_time_grid.html.erb +113 -0
- data/app/views/stuff_to_do/_time_grid_form.html.erb +32 -0
- data/app/views/stuff_to_do/index.html.erb +44 -0
- data/app/views/stuff_to_do_mailer/recommended_below_threshold.erb +3 -0
- data/app/views/stuff_to_do_mailer/recommended_below_threshold.text.html.rhtml +1 -0
- data/assets/images/b.png +0 -0
- data/assets/images/bl.png +0 -0
- data/assets/images/br.png +0 -0
- data/assets/images/closelabel.gif +0 -0
- data/assets/images/loading.gif +0 -0
- data/assets/images/tl.png +0 -0
- data/assets/images/tr.png +0 -0
- data/assets/javascripts/facebox.js +319 -0
- data/assets/javascripts/jquery-1.2.6.min.js +32 -0
- data/assets/javascripts/jquery-ui.js +2839 -0
- data/assets/javascripts/jquery.contextMenu.js +212 -0
- data/assets/javascripts/semantic.cache +15 -0
- data/assets/javascripts/stuff-to-do.js +270 -0
- data/assets/javascripts/ui/build.xml +24 -0
- data/assets/javascripts/ui/effects.blind.js +49 -0
- data/assets/javascripts/ui/effects.bounce.js +78 -0
- data/assets/javascripts/ui/effects.clip.js +54 -0
- data/assets/javascripts/ui/effects.core.js +510 -0
- data/assets/javascripts/ui/effects.drop.js +50 -0
- data/assets/javascripts/ui/effects.explode.js +79 -0
- data/assets/javascripts/ui/effects.fold.js +55 -0
- data/assets/javascripts/ui/effects.highlight.js +48 -0
- data/assets/javascripts/ui/effects.pulsate.js +55 -0
- data/assets/javascripts/ui/effects.scale.js +180 -0
- data/assets/javascripts/ui/effects.shake.js +57 -0
- data/assets/javascripts/ui/effects.slide.js +50 -0
- data/assets/javascripts/ui/effects.transfer.js +59 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ar.js +26 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-bg.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ca.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-cs.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-da.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-de.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-eo.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-es.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-fa.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-fi.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-fr.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-he.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-hr.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-hu.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-hy.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-id.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-is.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-it.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ja.js +26 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ko.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-lt.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-lv.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-nl.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-no.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-pl.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-pt-BR.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ro.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-ru.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-sk.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-sl.js +26 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-sq.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-sv.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-th.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-tr.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-uk.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-zh-CN.js +25 -0
- data/assets/javascripts/ui/i18n/ui.datepicker-zh-TW.js +25 -0
- data/assets/javascripts/ui/svn.log +11 -0
- data/assets/javascripts/ui/ui.accordion.js +400 -0
- data/assets/javascripts/ui/ui.core.js +533 -0
- data/assets/javascripts/ui/ui.datepicker.js +1754 -0
- data/assets/javascripts/ui/ui.dialog.js +630 -0
- data/assets/javascripts/ui/ui.draggable.js +696 -0
- data/assets/javascripts/ui/ui.droppable.js +314 -0
- data/assets/javascripts/ui/ui.progressbar.js +114 -0
- data/assets/javascripts/ui/ui.resizable.js +805 -0
- data/assets/javascripts/ui/ui.selectable.js +266 -0
- data/assets/javascripts/ui/ui.slider.js +552 -0
- data/assets/javascripts/ui/ui.sortable.js +1012 -0
- data/assets/javascripts/ui/ui.tabs.js +572 -0
- data/assets/stylesheets/stuff_to_do.css +216 -0
- data/config/locales/bg.yml +18 -0
- data/config/locales/ca-fr.yml +18 -0
- data/config/locales/cs.yml +16 -0
- data/config/locales/da.yml +16 -0
- data/config/locales/de.yml +18 -0
- data/config/locales/en.yml +24 -0
- data/config/locales/es.yml +19 -0
- data/config/locales/fr.yml +17 -0
- data/config/locales/hu.yml +16 -0
- data/config/locales/it.yml +16 -0
- data/config/locales/ja.yml +18 -0
- data/config/locales/ko.yml +18 -0
- data/config/locales/lt.yml +18 -0
- data/config/locales/nl.yml +20 -0
- data/config/locales/pt-BR.yml +18 -0
- data/config/locales/ru.yml +19 -0
- data/config/locales/sv.yml +19 -0
- data/config/locales/tr.yml +18 -0
- data/config/routes.rb +3 -0
- data/init.rb +54 -0
- data/lang/bg.yml +17 -0
- data/lang/ca-fr.yml +17 -0
- data/lang/cs.yml +15 -0
- data/lang/da.yml +15 -0
- data/lang/de.yml +17 -0
- data/lang/en.yml +21 -0
- data/lang/es.yml +18 -0
- data/lang/fr.yml +16 -0
- data/lang/hu.yml +15 -0
- data/lang/it.yml +15 -0
- data/lang/ja.yml +17 -0
- data/lang/ko.yml +17 -0
- data/lang/lt.yml +17 -0
- data/lang/pt-br.yml +17 -0
- data/lang/ru.yml +15 -0
- data/lang/sv.yml +18 -0
- data/lang/tr.yml +17 -0
- data/lib/redmine_stuff_to_do/stuff_to_do_compatibility.rb +15 -0
- data/lib/stuff_to_do_array_patch.rb +8 -0
- data/lib/stuff_to_do_issue_patch.rb +57 -0
- data/lib/stuff_to_do_project_patch.rb +31 -0
- data/lib/stuff_to_do_user_patch.rb +10 -0
- data/rails/init.rb +1 -0
- data/spec/controllers/stuff_to_do_controller_add_to_time_grid_spec.rb +58 -0
- data/spec/controllers/stuff_to_do_controller_index_spec.rb +155 -0
- data/spec/controllers/stuff_to_do_controller_remove_from_time_grid_spec.rb +56 -0
- data/spec/controllers/stuff_to_do_controller_reorder_spec.rb +179 -0
- data/spec/controllers/stuff_to_do_controller_save_time_entries_spec.rb +56 -0
- data/spec/controllers/stuff_to_do_private_methods_spec.rb +82 -0
- data/spec/lib/stuff_to_do_issue_patch_spec.rb +60 -0
- data/spec/lib/stuff_to_do_project_patch_spec.rb +50 -0
- data/spec/lib/stuff_to_do_user_patch_spec.rb +8 -0
- data/spec/models/stuff_to_do_filter_spec.rb +3 -0
- data/spec/models/stuff_to_do_mailer_spec.rb +42 -0
- data/spec/models/stuff_to_do_spec.rb +426 -0
- data/spec/sanity_spec.rb +7 -0
- data/spec/spec_helper.rb +130 -0
- metadata +211 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jQuery UI @VERSION
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about)
|
|
5
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
6
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
|
7
|
+
*
|
|
8
|
+
* http://docs.jquery.com/UI
|
|
9
|
+
*/
|
|
10
|
+
;(function($) {
|
|
11
|
+
|
|
12
|
+
var _remove = $.fn.remove,
|
|
13
|
+
isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
|
|
14
|
+
|
|
15
|
+
//Helper functions and ui object
|
|
16
|
+
$.ui = {
|
|
17
|
+
|
|
18
|
+
version: "@VERSION",
|
|
19
|
+
|
|
20
|
+
// $.ui.plugin is deprecated. Use the proxy pattern instead.
|
|
21
|
+
plugin: {
|
|
22
|
+
add: function(module, option, set) {
|
|
23
|
+
var proto = $.ui[module].prototype;
|
|
24
|
+
for(var i in set) {
|
|
25
|
+
proto.plugins[i] = proto.plugins[i] || [];
|
|
26
|
+
proto.plugins[i].push([option, set[i]]);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
call: function(instance, name, args) {
|
|
30
|
+
var set = instance.plugins[name];
|
|
31
|
+
if(!set) { return; }
|
|
32
|
+
|
|
33
|
+
for (var i = 0; i < set.length; i++) {
|
|
34
|
+
if (instance.options[set[i][0]]) {
|
|
35
|
+
set[i][1].apply(instance.element, args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
contains: function(a, b) {
|
|
42
|
+
var safari2 = $.browser.safari && $.browser.version < 522;
|
|
43
|
+
if (a.contains && !safari2) {
|
|
44
|
+
return a.contains(b);
|
|
45
|
+
}
|
|
46
|
+
if (a.compareDocumentPosition)
|
|
47
|
+
return !!(a.compareDocumentPosition(b) & 16);
|
|
48
|
+
while (b = b.parentNode)
|
|
49
|
+
if (b == a) return true;
|
|
50
|
+
return false;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
cssCache: {},
|
|
54
|
+
css: function(name) {
|
|
55
|
+
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
|
|
56
|
+
var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
|
|
57
|
+
|
|
58
|
+
//if (!$.browser.safari)
|
|
59
|
+
//tmp.appendTo('body');
|
|
60
|
+
|
|
61
|
+
//Opera and Safari set width and height to 0px instead of auto
|
|
62
|
+
//Safari returns rgba(0,0,0,0) when bgcolor is not set
|
|
63
|
+
$.ui.cssCache[name] = !!(
|
|
64
|
+
(!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
|
|
65
|
+
!(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
|
|
66
|
+
);
|
|
67
|
+
try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
|
|
68
|
+
return $.ui.cssCache[name];
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
hasScroll: function(el, a) {
|
|
72
|
+
|
|
73
|
+
//If overflow is hidden, the element might have extra content, but the user wants to hide it
|
|
74
|
+
if ($(el).css('overflow') == 'hidden') { return false; }
|
|
75
|
+
|
|
76
|
+
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
|
|
77
|
+
has = false;
|
|
78
|
+
|
|
79
|
+
if (el[scroll] > 0) { return true; }
|
|
80
|
+
|
|
81
|
+
// TODO: determine which cases actually cause this to happen
|
|
82
|
+
// if the element doesn't have the scroll set, see if it's possible to
|
|
83
|
+
// set the scroll
|
|
84
|
+
el[scroll] = 1;
|
|
85
|
+
has = (el[scroll] > 0);
|
|
86
|
+
el[scroll] = 0;
|
|
87
|
+
return has;
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
isOverAxis: function(x, reference, size) {
|
|
91
|
+
//Determines when x coordinate is over "b" element axis
|
|
92
|
+
return (x > reference) && (x < (reference + size));
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
isOver: function(y, x, top, left, height, width) {
|
|
96
|
+
//Determines when x, y coordinates is over "b" element
|
|
97
|
+
return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
keyCode: {
|
|
101
|
+
BACKSPACE: 8,
|
|
102
|
+
CAPS_LOCK: 20,
|
|
103
|
+
COMMA: 188,
|
|
104
|
+
CONTROL: 17,
|
|
105
|
+
DELETE: 46,
|
|
106
|
+
DOWN: 40,
|
|
107
|
+
END: 35,
|
|
108
|
+
ENTER: 13,
|
|
109
|
+
ESCAPE: 27,
|
|
110
|
+
HOME: 36,
|
|
111
|
+
INSERT: 45,
|
|
112
|
+
LEFT: 37,
|
|
113
|
+
NUMPAD_ADD: 107,
|
|
114
|
+
NUMPAD_DECIMAL: 110,
|
|
115
|
+
NUMPAD_DIVIDE: 111,
|
|
116
|
+
NUMPAD_ENTER: 108,
|
|
117
|
+
NUMPAD_MULTIPLY: 106,
|
|
118
|
+
NUMPAD_SUBTRACT: 109,
|
|
119
|
+
PAGE_DOWN: 34,
|
|
120
|
+
PAGE_UP: 33,
|
|
121
|
+
PERIOD: 190,
|
|
122
|
+
RIGHT: 39,
|
|
123
|
+
SHIFT: 16,
|
|
124
|
+
SPACE: 32,
|
|
125
|
+
TAB: 9,
|
|
126
|
+
UP: 38
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// WAI-ARIA normalization
|
|
132
|
+
if (isFF2) {
|
|
133
|
+
var attr = $.attr,
|
|
134
|
+
removeAttr = $.fn.removeAttr,
|
|
135
|
+
ariaNS = "http://www.w3.org/2005/07/aaa",
|
|
136
|
+
ariaState = /^aria-/,
|
|
137
|
+
ariaRole = /^wairole:/;
|
|
138
|
+
|
|
139
|
+
$.attr = function(elem, name, value) {
|
|
140
|
+
var set = value !== undefined;
|
|
141
|
+
|
|
142
|
+
return (name == 'role'
|
|
143
|
+
? (set
|
|
144
|
+
? attr.call(this, elem, name, "wairole:" + value)
|
|
145
|
+
: (attr.apply(this, arguments) || "").replace(ariaRole, ""))
|
|
146
|
+
: (ariaState.test(name)
|
|
147
|
+
? (set
|
|
148
|
+
? elem.setAttributeNS(ariaNS,
|
|
149
|
+
name.replace(ariaState, "aaa:"), value)
|
|
150
|
+
: attr.call(this, elem, name.replace(ariaState, "aaa:")))
|
|
151
|
+
: attr.apply(this, arguments)));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
$.fn.removeAttr = function(name) {
|
|
155
|
+
return (ariaState.test(name)
|
|
156
|
+
? this.each(function() {
|
|
157
|
+
this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
|
|
158
|
+
}) : removeAttr.call(this, name));
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//jQuery plugins
|
|
163
|
+
$.fn.extend({
|
|
164
|
+
|
|
165
|
+
remove: function() {
|
|
166
|
+
// Safari has a native remove event which actually removes DOM elements,
|
|
167
|
+
// so we have to use triggerHandler instead of trigger (#3037).
|
|
168
|
+
$("*", this).add(this).each(function() {
|
|
169
|
+
$(this).triggerHandler("remove");
|
|
170
|
+
});
|
|
171
|
+
return _remove.apply(this, arguments );
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
enableSelection: function() {
|
|
175
|
+
return this
|
|
176
|
+
.attr('unselectable', 'off')
|
|
177
|
+
.css('MozUserSelect', '')
|
|
178
|
+
.unbind('selectstart.ui');
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
disableSelection: function() {
|
|
182
|
+
return this
|
|
183
|
+
.attr('unselectable', 'on')
|
|
184
|
+
.css('MozUserSelect', 'none')
|
|
185
|
+
.bind('selectstart.ui', function() { return false; });
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
scrollParent: function() {
|
|
189
|
+
|
|
190
|
+
var scrollParent;
|
|
191
|
+
if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
|
|
192
|
+
scrollParent = this.parents().filter(function() {
|
|
193
|
+
return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
|
194
|
+
}).eq(0);
|
|
195
|
+
} else {
|
|
196
|
+
scrollParent = this.parents().filter(function() {
|
|
197
|
+
return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
|
|
198
|
+
}).eq(0);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
//Additional selectors
|
|
210
|
+
$.extend($.expr[':'], {
|
|
211
|
+
|
|
212
|
+
data: function(a, i, m) {
|
|
213
|
+
return $.data(a, m[3]);
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
// TODO: add support for object, area
|
|
217
|
+
tabbable: function(a, i, m) {
|
|
218
|
+
|
|
219
|
+
var nodeName = a.nodeName.toLowerCase();
|
|
220
|
+
function isVisible(element) {
|
|
221
|
+
return !($(element).is(':hidden') || $(element).parents(':hidden').length);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
// in tab order
|
|
226
|
+
a.tabIndex >= 0 &&
|
|
227
|
+
|
|
228
|
+
( // filter node types that participate in the tab order
|
|
229
|
+
|
|
230
|
+
// anchor tag
|
|
231
|
+
('a' == nodeName && a.href) ||
|
|
232
|
+
|
|
233
|
+
// enabled form element
|
|
234
|
+
(/input|select|textarea|button/.test(nodeName) &&
|
|
235
|
+
'hidden' != a.type && !a.disabled)
|
|
236
|
+
) &&
|
|
237
|
+
|
|
238
|
+
// visible on page
|
|
239
|
+
isVisible(a)
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
// $.widget is a factory to create jQuery plugins
|
|
248
|
+
// taking some boilerplate code out of the plugin code
|
|
249
|
+
function getter(namespace, plugin, method, args) {
|
|
250
|
+
function getMethods(type) {
|
|
251
|
+
var methods = $[namespace][plugin][type] || [];
|
|
252
|
+
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var methods = getMethods('getter');
|
|
256
|
+
if (args.length == 1 && typeof args[0] == 'string') {
|
|
257
|
+
methods = methods.concat(getMethods('getterSetter'));
|
|
258
|
+
}
|
|
259
|
+
return ($.inArray(method, methods) != -1);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
$.widget = function(name, prototype) {
|
|
263
|
+
var namespace = name.split(".")[0];
|
|
264
|
+
name = name.split(".")[1];
|
|
265
|
+
|
|
266
|
+
// create plugin method
|
|
267
|
+
$.fn[name] = function(options) {
|
|
268
|
+
var isMethodCall = (typeof options == 'string'),
|
|
269
|
+
args = Array.prototype.slice.call(arguments, 1);
|
|
270
|
+
|
|
271
|
+
// prevent calls to internal methods
|
|
272
|
+
if (isMethodCall && options.substring(0, 1) == '_') {
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// handle getter methods
|
|
277
|
+
if (isMethodCall && getter(namespace, name, options, args)) {
|
|
278
|
+
var instance = $.data(this[0], name);
|
|
279
|
+
return (instance ? instance[options].apply(instance, args)
|
|
280
|
+
: undefined);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// handle initialization and non-getter methods
|
|
284
|
+
return this.each(function() {
|
|
285
|
+
var instance = $.data(this, name);
|
|
286
|
+
|
|
287
|
+
// constructor
|
|
288
|
+
(!instance && !isMethodCall &&
|
|
289
|
+
$.data(this, name, new $[namespace][name](this, options)));
|
|
290
|
+
|
|
291
|
+
// method call
|
|
292
|
+
(instance && isMethodCall && $.isFunction(instance[options]) &&
|
|
293
|
+
instance[options].apply(instance, args));
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// create widget constructor
|
|
298
|
+
$[namespace] = $[namespace] || {};
|
|
299
|
+
$[namespace][name] = function(element, options) {
|
|
300
|
+
var self = this;
|
|
301
|
+
|
|
302
|
+
this.namespace = namespace;
|
|
303
|
+
this.widgetName = name;
|
|
304
|
+
this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
|
|
305
|
+
this.widgetBaseClass = namespace + '-' + name;
|
|
306
|
+
|
|
307
|
+
this.options = $.extend({},
|
|
308
|
+
$.widget.defaults,
|
|
309
|
+
$[namespace][name].defaults,
|
|
310
|
+
$.metadata && $.metadata.get(element)[name],
|
|
311
|
+
options);
|
|
312
|
+
|
|
313
|
+
this.element = $(element)
|
|
314
|
+
.bind('setData.' + name, function(event, key, value) {
|
|
315
|
+
return self._setData(key, value);
|
|
316
|
+
})
|
|
317
|
+
.bind('getData.' + name, function(event, key) {
|
|
318
|
+
return self._getData(key);
|
|
319
|
+
})
|
|
320
|
+
.bind('remove', function() {
|
|
321
|
+
return self.destroy();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
this._init();
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// add widget prototype
|
|
328
|
+
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
|
|
329
|
+
|
|
330
|
+
// TODO: merge getter and getterSetter properties from widget prototype
|
|
331
|
+
// and plugin prototype
|
|
332
|
+
$[namespace][name].getterSetter = 'option';
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
$.widget.prototype = {
|
|
336
|
+
_init: function() {},
|
|
337
|
+
destroy: function() {
|
|
338
|
+
this.element.removeData(this.widgetName)
|
|
339
|
+
.removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
|
|
340
|
+
.removeAttr('aria-disabled');
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
option: function(key, value) {
|
|
344
|
+
var options = key,
|
|
345
|
+
self = this;
|
|
346
|
+
|
|
347
|
+
if (typeof key == "string") {
|
|
348
|
+
if (value === undefined) {
|
|
349
|
+
return this._getData(key);
|
|
350
|
+
}
|
|
351
|
+
options = {};
|
|
352
|
+
options[key] = value;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
$.each(options, function(key, value) {
|
|
356
|
+
self._setData(key, value);
|
|
357
|
+
});
|
|
358
|
+
},
|
|
359
|
+
_getData: function(key) {
|
|
360
|
+
return this.options[key];
|
|
361
|
+
},
|
|
362
|
+
_setData: function(key, value) {
|
|
363
|
+
this.options[key] = value;
|
|
364
|
+
|
|
365
|
+
if (key == 'disabled') {
|
|
366
|
+
this.element[value ? 'addClass' : 'removeClass'](
|
|
367
|
+
this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
|
|
368
|
+
.attr("aria-disabled", value);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
enable: function() {
|
|
373
|
+
this._setData('disabled', false);
|
|
374
|
+
},
|
|
375
|
+
disable: function() {
|
|
376
|
+
this._setData('disabled', true);
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
_trigger: function(type, event, data) {
|
|
380
|
+
var eventName = (type == this.widgetEventPrefix
|
|
381
|
+
? type : this.widgetEventPrefix + type);
|
|
382
|
+
event = event || $.event.fix({ type: eventName, target: this.element[0] });
|
|
383
|
+
return this.element.triggerHandler(eventName, [event, data], this.options[type]);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
$.widget.defaults = {
|
|
388
|
+
disabled: false
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
/** Mouse Interaction Plugin **/
|
|
393
|
+
|
|
394
|
+
$.ui.mouse = {
|
|
395
|
+
_mouseInit: function() {
|
|
396
|
+
var self = this;
|
|
397
|
+
|
|
398
|
+
this.element
|
|
399
|
+
.bind('mousedown.'+this.widgetName, function(event) {
|
|
400
|
+
return self._mouseDown(event);
|
|
401
|
+
})
|
|
402
|
+
.bind('click.'+this.widgetName, function(event) {
|
|
403
|
+
if(self._preventClickEvent) {
|
|
404
|
+
self._preventClickEvent = false;
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// Prevent text selection in IE
|
|
410
|
+
if ($.browser.msie) {
|
|
411
|
+
this._mouseUnselectable = this.element.attr('unselectable');
|
|
412
|
+
this.element.attr('unselectable', 'on');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
this.started = false;
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
// TODO: make sure destroying one instance of mouse doesn't mess with
|
|
419
|
+
// other instances of mouse
|
|
420
|
+
_mouseDestroy: function() {
|
|
421
|
+
this.element.unbind('.'+this.widgetName);
|
|
422
|
+
|
|
423
|
+
// Restore text selection in IE
|
|
424
|
+
($.browser.msie
|
|
425
|
+
&& this.element.attr('unselectable', this._mouseUnselectable));
|
|
426
|
+
},
|
|
427
|
+
|
|
428
|
+
_mouseDown: function(event) {
|
|
429
|
+
// we may have missed mouseup (out of window)
|
|
430
|
+
(this._mouseStarted && this._mouseUp(event));
|
|
431
|
+
|
|
432
|
+
this._mouseDownEvent = event;
|
|
433
|
+
|
|
434
|
+
var self = this,
|
|
435
|
+
btnIsLeft = (event.which == 1),
|
|
436
|
+
elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
|
|
437
|
+
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.mouseDelayMet = !this.options.delay;
|
|
442
|
+
if (!this.mouseDelayMet) {
|
|
443
|
+
this._mouseDelayTimer = setTimeout(function() {
|
|
444
|
+
self.mouseDelayMet = true;
|
|
445
|
+
}, this.options.delay);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
|
449
|
+
this._mouseStarted = (this._mouseStart(event) !== false);
|
|
450
|
+
if (!this._mouseStarted) {
|
|
451
|
+
event.preventDefault();
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// these delegates are required to keep context
|
|
457
|
+
this._mouseMoveDelegate = function(event) {
|
|
458
|
+
return self._mouseMove(event);
|
|
459
|
+
};
|
|
460
|
+
this._mouseUpDelegate = function(event) {
|
|
461
|
+
return self._mouseUp(event);
|
|
462
|
+
};
|
|
463
|
+
$(document)
|
|
464
|
+
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
|
465
|
+
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
|
466
|
+
|
|
467
|
+
// preventDefault() is used to prevent the selection of text here -
|
|
468
|
+
// however, in Safari, this causes select boxes not to be selectable
|
|
469
|
+
// anymore, so this fix is needed
|
|
470
|
+
if(!$.browser.safari) event.preventDefault();
|
|
471
|
+
return true;
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
_mouseMove: function(event) {
|
|
475
|
+
// IE mouseup check - mouseup happened when mouse was out of window
|
|
476
|
+
if ($.browser.msie && !event.button) {
|
|
477
|
+
return this._mouseUp(event);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (this._mouseStarted) {
|
|
481
|
+
this._mouseDrag(event);
|
|
482
|
+
return event.preventDefault();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
|
486
|
+
this._mouseStarted =
|
|
487
|
+
(this._mouseStart(this._mouseDownEvent, event) !== false);
|
|
488
|
+
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return !this._mouseStarted;
|
|
492
|
+
},
|
|
493
|
+
|
|
494
|
+
_mouseUp: function(event) {
|
|
495
|
+
$(document)
|
|
496
|
+
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
|
497
|
+
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
|
498
|
+
|
|
499
|
+
if (this._mouseStarted) {
|
|
500
|
+
this._mouseStarted = false;
|
|
501
|
+
this._preventClickEvent = true;
|
|
502
|
+
this._mouseStop(event);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return false;
|
|
506
|
+
},
|
|
507
|
+
|
|
508
|
+
_mouseDistanceMet: function(event) {
|
|
509
|
+
return (Math.max(
|
|
510
|
+
Math.abs(this._mouseDownEvent.pageX - event.pageX),
|
|
511
|
+
Math.abs(this._mouseDownEvent.pageY - event.pageY)
|
|
512
|
+
) >= this.options.distance
|
|
513
|
+
);
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
_mouseDelayMet: function(event) {
|
|
517
|
+
return this.mouseDelayMet;
|
|
518
|
+
},
|
|
519
|
+
|
|
520
|
+
// These are placeholder methods, to be overriden by extending plugin
|
|
521
|
+
_mouseStart: function(event) {},
|
|
522
|
+
_mouseDrag: function(event) {},
|
|
523
|
+
_mouseStop: function(event) {},
|
|
524
|
+
_mouseCapture: function(event) { return true; }
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
$.ui.mouse.defaults = {
|
|
528
|
+
cancel: null,
|
|
529
|
+
distance: 1,
|
|
530
|
+
delay: 0
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
})(jQuery);
|