Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b4a1e1

Browse filesBrowse files
author
Tero Piirainen
committed
First new items for jQuery Tools 1.3.0
1 parent 1b0546c commit 3b4a1e1
Copy full SHA for 3b4a1e1

File tree

Expand file treeCollapse file tree

3 files changed

+454
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+454
-0
lines changed

‎src/accordion/accordion.js

Copy file name to clipboard
+91Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
(function($) {
3+
$.fn.accordion = function(options) {
4+
var DEFAULTS = {
5+
orientation: "vertical",
6+
min: 0,
7+
max: 200,
8+
sticky: false,
9+
event: "mouseenter",
10+
duration: 500,
11+
pane: ".pane",
12+
defaultPane: 0
13+
};
14+
15+
options = $.extend(DEFAULTS, options);
16+
17+
this.each(function() {
18+
var panes = $(options.pane, this);
19+
var currentPane;
20+
var dummy = document.createElement("span");
21+
22+
if (panes.length) {
23+
if (options.orientation == "vertical") {
24+
var STYLE_PROPERTY = "height";
25+
var OFFSET_PROPERTY = "offsetHeight";
26+
} else {
27+
STYLE_PROPERTY = "width";
28+
OFFSET_PROPERTY = "offsetWidth";
29+
30+
$(this).next().css({clear: "left"});
31+
var lastPane = panes.get(panes.length - 1);
32+
$(this).css({
33+
width: lastPane.offsetLeft + lastPane.offsetWidth - panes[0].offsetLeft,
34+
height: lastPane.offsetHeight,
35+
overflow: "hidden"
36+
});
37+
}
38+
39+
var size = panes[0][OFFSET_PROPERTY];
40+
41+
panes.bind(options.event, function() {
42+
currentPane = this;
43+
animatePanes(options.max, options.min);
44+
});
45+
46+
if (options.sticky) {
47+
currentPane = panes.get(options.defaultPane);
48+
animatePanes(options.max, options.min, 1);
49+
} else {
50+
$(this).mouseleave(function() {
51+
animatePanes(size);
52+
});
53+
}
54+
}
55+
56+
function animatePanes(max, min, duration) {
57+
if (!currentPane) return;
58+
59+
if (duration == null) duration = options.duration;
60+
61+
var totalSize = size * panes.length;
62+
63+
var sizes = [];
64+
panes.each(function(i) {
65+
sizes[i] = this[OFFSET_PROPERTY];
66+
});
67+
68+
var collapsedSize = min || Math.round((totalSize - max) / (panes.length - 1));
69+
70+
$(dummy).stop();
71+
dummy.style.step = 0;
72+
$(dummy).animate({step: 1}, {
73+
duration: duration,
74+
easing: options.easing,
75+
step: function(step) {
76+
var expandedSize = totalSize;
77+
for (var i = 0, pane; pane = panes[i]; i++) {
78+
if (pane != currentPane) {
79+
var value = sizes[i] + Math.round(step * (collapsedSize - sizes[i]));
80+
if (value < 0) value = 0;
81+
pane.style[STYLE_PROPERTY] = value + "px";
82+
expandedSize -= value;
83+
}
84+
}
85+
currentPane.style[STYLE_PROPERTY] = expandedSize + "px";
86+
}
87+
});
88+
};
89+
});
90+
};
91+
})(jQuery);

‎src/form/form.upload.js

Copy file name to clipboard
+244Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
/*!
2+
* A front-end script for uploadify.swf (http://www.uploadify.com)
3+
* Experimental stuff. Used by Flowplayer setup in 2010
4+
*
5+
* http://flowplayer.org/setup/
6+
*
7+
* @author Tero Piirainen
8+
* @license MIT, GPL2+
9+
*
10+
* TODO
11+
* - :file input replaceWith(wrap)
12+
*/
13+
(function() {
14+
15+
$.tools = $.tools || {version: '@VERSION'};
16+
17+
var tool = $.tools.upload = {
18+
19+
conf: {
20+
pagepath: '/setup/upload/',
21+
buttonText: 'Select file',
22+
script: '/setup/actions/uploadMedia',
23+
folder: '',
24+
method: 'POST',
25+
26+
queueSizeLimit: 1,
27+
simUploadLimit: 1,
28+
29+
sizeLimit: 6000,
30+
fileDataName: 'Filedata',
31+
32+
// JQT stuff
33+
autoStart: false,
34+
progress: null,
35+
36+
css: {
37+
root: 'uploadRoot',
38+
progress: 'uploadProgress',
39+
items: 'uploadItems',
40+
item: 'uploadItem',
41+
active: 'active'
42+
},
43+
44+
swf: {
45+
width: 110,
46+
height: 30,
47+
src: null,
48+
version: [9, 24]
49+
}
50+
}
51+
};
52+
53+
54+
function prettyPrint(file) {
55+
var name = file.name, size = file.size / 1024;
56+
57+
if (name.length > 20) { name = file.name.substring(0, 20) + " &hellip;"; }
58+
size = size > 1000 ? Math.round(size / 10) * .01 + " Mb" : Math.round(size) + " kb";
59+
60+
return "<strong>" + name + "</strong> (" + size + ")";
61+
}
62+
63+
function findOrCreate(context, query) {
64+
if (query.substring(0, 1) == '#') { return $(query); }
65+
var el = context.parent().find("." + query);
66+
67+
if (!el.length) {
68+
el = $("<div/>").addClass(query);
69+
context.after(el);
70+
return el;
71+
}
72+
}
73+
74+
function Upload(input, conf, index) {
75+
76+
var self = this,
77+
swfWrap = input.parent().next(),
78+
css = conf.css;
79+
80+
// id attribute required for input field
81+
conf.uploadifyID = input.attr("id") || "upload";
82+
input.attr("id", conf.uploadifyID).hide();
83+
84+
conf.script += "?name=" + input.attr("name");
85+
conf.swf.id = conf.swf.id || 'foo';
86+
87+
88+
// progress and info elements
89+
var progress = findOrCreate(swfWrap, css.progress);
90+
91+
// install SWF component
92+
var api = flashembed(swfWrap.get(0), conf.swf, conf).getApi();
93+
94+
95+
// The Upload API
96+
$.extend(self, {
97+
98+
getConf: function() {
99+
return conf;
100+
},
101+
102+
getRoot: function() {
103+
return swfWrap;
104+
},
105+
106+
getProgress: function() {
107+
return progress;
108+
},
109+
110+
getProgressItems: function() {
111+
return progress.find("." + css.items);
112+
},
113+
114+
start: function() {
115+
var e = new $.Event("uploadifyBeforeStart");
116+
input.trigger(e);
117+
118+
if (!e.isDefaultPrevented()) {
119+
input.trigger("uploadifyStart");
120+
api.startFileUpload(null, true);
121+
}
122+
},
123+
124+
// bind / unbind
125+
bind: function(name, fn) {
126+
input.bind(name.replace("on", "uploadify"), function() {
127+
fn.apply(self, arguments);
128+
});
129+
return self;
130+
},
131+
132+
unbind: function(name) {
133+
input.unbind(name.replace("on", "uploadify"));
134+
return self;
135+
}
136+
137+
});
138+
139+
140+
// define callbacks
141+
$.each("Select,BeforeStart,Start,Cancel,Error,Progress,Complete,AllComplete".split(","), function(i, name) {
142+
143+
name = "on" + name;
144+
145+
// configuration
146+
if ($.isFunction(conf[name])) {
147+
self.bind(name, conf[name]);
148+
}
149+
150+
// API method
151+
self[name] = function(fn) {
152+
return self.bind(name, fn);
153+
};
154+
155+
});
156+
157+
158+
// assign callbacks (to the end of queue)
159+
self.onSelect(function(event, fileId, file) {
160+
161+
// root for the items
162+
var items = self.getProgressItems();
163+
164+
if (!items.length) {
165+
items = $("<div/>").addClass(css.items);
166+
progress.append(items);
167+
}
168+
169+
// single item
170+
var item = $("#" + fileId), am = items.find("." + css.item).length;
171+
172+
173+
// queue is full
174+
if (am == conf.queueSizeLimit) {
175+
var old = items.children(":first");
176+
api.cancelFileUpload(old.attr("id"), true, true);
177+
old.remove();
178+
}
179+
180+
// add to queue
181+
if (!item.length) {
182+
item = $("<div><small/><span/></div>").attr("id", fileId).addClass(css.item);
183+
item.find("small").html(prettyPrint(file));
184+
items.append(item);
185+
}
186+
187+
if (conf.autoStart) {
188+
self.start();
189+
}
190+
191+
});
192+
193+
194+
self.onStart(function() {
195+
progress.addClass(css.active);
196+
});
197+
198+
self.onComplete(function() {
199+
progress.removeClass(css.active);
200+
api.clearFileUploadQueue(false);
201+
});
202+
203+
self.onProgress(function(event, fileId, file, data) {
204+
var item = $("#" + fileId);
205+
item.find("span").css({display: 'block', width: data.percentage + "%"});
206+
});
207+
208+
}
209+
210+
/* Flash API
211+
cancelFileUpload(key, true, true)
212+
startFileUpload(fileId || null, true)
213+
startFileUpload(null, true)
214+
updateSettings(settingName, settingValue)
215+
startFileUpload(ID, false)
216+
cancelFileUpload(ID, true, false)
217+
clearFileUploadQueue(false)
218+
*/
219+
220+
// jQuery plugin implementation
221+
$.fn.upload = function(conf) {
222+
223+
// already constructed --> return API
224+
var el = this.eq(typeof conf == 'number' ? conf : 0).data("upload");
225+
if (el) { return el; }
226+
227+
conf = $.extend(true, $.extend({}, tool.conf), conf);
228+
229+
this.each(function(index) {
230+
el = new Upload($(this), conf);
231+
$(this).data("upload", el, index);
232+
});
233+
234+
return conf.api ? el: this;
235+
236+
};
237+
238+
})();
239+
240+
241+
242+
243+
244+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.