nivo 0.0.2
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/.DS_Store +0 -0
- data/.gitignore +4 -0
- data/Gemfile +15 -0
- data/README.md +76 -0
- data/Rakefile +38 -0
- data/app/.DS_Store +0 -0
- data/app/controllers/.DS_Store +0 -0
- data/app/controllers/nivo/manage_slides_controller.rb +19 -0
- data/app/controllers/nivo/slides_controller.rb +55 -0
- data/app/models/.DS_Store +0 -0
- data/app/models/nivo/slide.rb +60 -0
- data/app/views/.DS_Store +0 -0
- data/app/views/nivo/_slideshow.html.haml +14 -0
- data/app/views/nivo/slides/_form.html.haml +27 -0
- data/app/views/nivo/slides/_search.html.haml +5 -0
- data/app/views/nivo/slides/edit.html.haml +5 -0
- data/app/views/nivo/slides/index.html.haml +26 -0
- data/app/views/nivo/slides/index.js.haml +2 -0
- data/app/views/nivo/slides/new.html.haml +6 -0
- data/app/views/nivo/slides/show.html.haml +19 -0
- data/config/.DS_Store +0 -0
- data/config/nivo_config.yml +34 -0
- data/config/routes.rb +15 -0
- data/lib/.DS_Store +0 -0
- data/lib/engine.rb +34 -0
- data/lib/nivo/config.rb +8 -0
- data/lib/nivo/helper.rb +14 -0
- data/lib/nivo/manage_slides.rb +17 -0
- data/lib/nivo/version.rb +3 -0
- data/lib/nivo.rb +13 -0
- data/lib/rails/.DS_Store +0 -0
- data/lib/rails/generators/.DS_Store +0 -0
- data/lib/rails/generators/nivo/.DS_Store +0 -0
- data/lib/rails/generators/nivo/controller_generator.rb +18 -0
- data/lib/rails/generators/nivo/install_generator.rb +49 -0
- data/lib/rails/generators/nivo/stylesheet_generator.rb +18 -0
- data/lib/rails/generators/nivo/templates/migration.rb +12 -0
- data/lib/rails/generators/nivo/templates/nivo_config.yml +29 -0
- data/lib/rails/generators/nivo/templates/schema.rb +15 -0
- data/lib/rails/generators/nivo/views_generator.rb +18 -0
- data/lib/rails/railties/tasks.rake +0 -0
- data/nivo.gemspec +28 -0
- data/public/.DS_Store +0 -0
- data/public/images/.DS_Store +0 -0
- data/public/images/arrows.png +0 -0
- data/public/images/bullets.png +0 -0
- data/public/images/loading.gif +0 -0
- data/public/javascripts/.DS_Store +0 -0
- data/public/javascripts/nivo-admin.js +10 -0
- data/public/javascripts/nivo-dragsort.js +288 -0
- data/public/javascripts/nivo-serialize.js +98 -0
- data/public/javascripts/nivo-settings.js +6 -0
- data/public/javascripts/nivo-slider.js +685 -0
- data/public/stylesheets/.DS_Store +0 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/public/stylesheets/default.css +75 -0
- data/public/stylesheets/nivo-slider.css +89 -0
- data/test/.DS_Store +0 -0
- data/test/helper.rb +18 -0
- data/test/test_nivo.rb +10 -0
- metadata +157 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
slide_dimensions:
|
3
|
+
original: '500x500>'
|
4
|
+
slide: '300x300#'
|
5
|
+
thumb: '100x100>'
|
6
|
+
|
7
|
+
caption: false
|
8
|
+
|
9
|
+
nivo_options:
|
10
|
+
effect: 'random' # Specify sets like: 'fold,fade,sliceDown'
|
11
|
+
slices: 15 # For slice animations
|
12
|
+
boxCols: 8 # For box animations
|
13
|
+
boxRows: 4 # For box animations
|
14
|
+
animSpeed: 500 # Slide transition speed
|
15
|
+
pauseTime: 3000 # How long each slide will show
|
16
|
+
startSlide: 0 # Set starting Slide (0 index)
|
17
|
+
directionNav: true # Next & Prev navigation
|
18
|
+
directionNavHide: true # Only show on hover
|
19
|
+
controlNav: true # 1,2,3... navigation
|
20
|
+
controlNavThumbs: false # Use thumbnails for Control Nav
|
21
|
+
controlNavThumbsFromRel: false # Use image rel for thumbs
|
22
|
+
controlNavThumbsSearch: '.jpg' # Replace this with...
|
23
|
+
controlNavThumbsReplace: '_thumb.jpg' # ...this in thumb Image src
|
24
|
+
keyboardNav: true # Use left & right arrows
|
25
|
+
pauseOnHover: true # Stop animation while hovering
|
26
|
+
manualAdvance: false # Force manual transitions
|
27
|
+
captionOpacity: 0.8 # Universal caption opacity
|
28
|
+
prevText: 'Prev' # Prev directionNav text
|
29
|
+
nextText: 'Next' # Next directionNav text
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 0) do
|
2
|
+
create_table :slides, :force => true do |t|
|
3
|
+
t.string :caption
|
4
|
+
t.string :url
|
5
|
+
t.boolean :active
|
6
|
+
t.integer :position
|
7
|
+
t.integer :width
|
8
|
+
t.integer :height
|
9
|
+
t.string :image_file_name
|
10
|
+
t.string :image_content_type
|
11
|
+
t.integer :image_file_size
|
12
|
+
t.datetime :image_updated_at
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Nivo
|
5
|
+
module Generators
|
6
|
+
class ViewsGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path("../../../../../app/views", __FILE__)
|
8
|
+
desc "Copies all Nivo views to your application."
|
9
|
+
|
10
|
+
argument :scope, :required => false, :default => nil,
|
11
|
+
:desc => "The scope to copy views to"
|
12
|
+
|
13
|
+
def copy_views
|
14
|
+
directory "nivo", "app/views/#{scope || :nivo}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
data/nivo.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nivo/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nivo"
|
7
|
+
s.version = Nivo::VERSION
|
8
|
+
s.authors = ["Ross Nelson"]
|
9
|
+
s.email = ["axcess1@me.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Easily add nivo slider and slide management to dust}
|
12
|
+
s.description = %q{Easily add nivo slider and slide management to dust}
|
13
|
+
|
14
|
+
s.rubyforge_project = "nivo"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
##
|
22
|
+
# specify any dependencies here; for example:
|
23
|
+
#
|
24
|
+
s.add_development_dependency "shoulda"
|
25
|
+
s.add_runtime_dependency "jquery-rails"
|
26
|
+
s.add_runtime_dependency "paperclip"
|
27
|
+
s.add_runtime_dependency "haml"
|
28
|
+
end
|
data/public/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,288 @@
|
|
1
|
+
// jQuery List DragSort v0.4
|
2
|
+
// Website: http://dragsort.codeplex.com/
|
3
|
+
// License: http://dragsort.codeplex.com/license
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
$.fn.slidedragsort = function(options) {
|
8
|
+
var opts = $.extend({}, $.fn.slidedragsort.defaults, options);
|
9
|
+
var lists = [];
|
10
|
+
var list = null, lastPos = null;
|
11
|
+
if (this.selector)
|
12
|
+
$("head").append("<style type='text/css'>" + (this.selector.split(",").join(" " + opts.dragSelector + ",") + " " + opts.dragSelector) + " { cursor: pointer; }</style>");
|
13
|
+
|
14
|
+
this.each(function(i, cont) {
|
15
|
+
|
16
|
+
if ($(cont).is("table") && $(cont).children().size() == 1 && $(cont).children().is("tbody"))
|
17
|
+
cont = $(cont).children().get(0);
|
18
|
+
|
19
|
+
var newList = {
|
20
|
+
draggedItem: null,
|
21
|
+
placeHolderItem: null,
|
22
|
+
pos: null,
|
23
|
+
offset: null,
|
24
|
+
offsetLimit: null,
|
25
|
+
scroll: null,
|
26
|
+
container: cont,
|
27
|
+
|
28
|
+
init: function() {
|
29
|
+
$(this.container).attr("data-listIdx", i).mousedown(this.grabItem).find(opts.dragSelector).css("cursor", "pointer");
|
30
|
+
$(this.container).children(opts.itemSelector).each(function(j) { $(this).attr("data-itemIdx", j); });
|
31
|
+
},
|
32
|
+
|
33
|
+
grabItem: function(e) {
|
34
|
+
if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude))
|
35
|
+
return;
|
36
|
+
|
37
|
+
var elm = e.target;
|
38
|
+
while (!$(elm).is("[data-listIdx='" + $(this).attr("data-listIdx") + "'] " + opts.dragSelector)) {
|
39
|
+
if (elm == this) return;
|
40
|
+
elm = elm.parentNode;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (list != null && list.draggedItem != null)
|
44
|
+
list.dropItem();
|
45
|
+
|
46
|
+
$(e.target).css("cursor", "move");
|
47
|
+
|
48
|
+
list = lists[$(this).attr("data-listIdx")];
|
49
|
+
list.draggedItem = $(elm).closest(opts.itemSelector);
|
50
|
+
var mt = parseInt(list.draggedItem.css("marginTop"));
|
51
|
+
var ml = parseInt(list.draggedItem.css("marginLeft"));
|
52
|
+
list.offset = list.draggedItem.offset();
|
53
|
+
list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
|
54
|
+
list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
|
55
|
+
|
56
|
+
if (!opts.dragBetween) {
|
57
|
+
var containerHeight = $(list.container).outerHeight() == 0 ? Math.max(1, Math.round(0.5 + $(list.container).children(opts.itemSelector).size() * list.draggedItem.outerWidth() / $(list.container).outerWidth())) * list.draggedItem.outerHeight() : $(list.container).outerHeight();
|
58
|
+
list.offsetLimit = $(list.container).offset();
|
59
|
+
list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
|
60
|
+
list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
|
61
|
+
}
|
62
|
+
|
63
|
+
var h = list.draggedItem.height();
|
64
|
+
var w = list.draggedItem.width();
|
65
|
+
var orig = list.draggedItem.attr("style");
|
66
|
+
list.draggedItem.attr("data-origStyle", orig ? orig : "");
|
67
|
+
if (opts.itemSelector == "tr") {
|
68
|
+
list.draggedItem.children().each(function() { $(this).width($(this).width()); });
|
69
|
+
list.placeHolderItem = list.draggedItem.clone().attr("data-placeHolder", true);
|
70
|
+
list.draggedItem.after(list.placeHolderItem);
|
71
|
+
list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html(" "); });
|
72
|
+
} else {
|
73
|
+
list.draggedItem.after(opts.placeHolderTemplate);
|
74
|
+
list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeHolder", true);
|
75
|
+
}
|
76
|
+
list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
|
77
|
+
|
78
|
+
$(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
|
79
|
+
|
80
|
+
list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
|
81
|
+
list.scroll.scrollY = window.setInterval(function() {
|
82
|
+
if (opts.scrollContainer != window) {
|
83
|
+
$(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
var t = $(opts.scrollContainer).scrollTop();
|
87
|
+
if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
|
88
|
+
$(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
|
89
|
+
list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
|
90
|
+
}
|
91
|
+
}, 10);
|
92
|
+
list.scroll.scrollX = window.setInterval(function() {
|
93
|
+
if (opts.scrollContainer != window) {
|
94
|
+
$(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
var l = $(opts.scrollContainer).scrollLeft();
|
98
|
+
if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
|
99
|
+
$(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
|
100
|
+
list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
|
101
|
+
}
|
102
|
+
}, 10);
|
103
|
+
|
104
|
+
list.setPos(e.pageX, e.pageY);
|
105
|
+
$(document).bind("selectstart", list.stopBubble); //stop ie text selection
|
106
|
+
$(document).bind("mousemove", list.swapItems);
|
107
|
+
$(document).bind("mouseup", list.dropItem);
|
108
|
+
if (opts.scrollContainer != window)
|
109
|
+
$(window).bind("DOMMouseScroll mousewheel", list.wheel);
|
110
|
+
return false; //stop moz text selection
|
111
|
+
},
|
112
|
+
|
113
|
+
setPos: function(x, y) {
|
114
|
+
var top = y - this.offset.top;
|
115
|
+
var left = x - this.offset.left;
|
116
|
+
|
117
|
+
if (!opts.dragBetween) {
|
118
|
+
top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
|
119
|
+
left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
|
120
|
+
}
|
121
|
+
|
122
|
+
this.draggedItem.parents().each(function() {
|
123
|
+
if ($(this).css("position") != "static" && (!$.browser.mozilla || $(this).css("display") != "table")) {
|
124
|
+
var offset = $(this).offset();
|
125
|
+
top -= offset.top;
|
126
|
+
left -= offset.left;
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
if (opts.scrollContainer == window) {
|
132
|
+
y -= $(window).scrollTop();
|
133
|
+
x -= $(window).scrollLeft();
|
134
|
+
y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
|
135
|
+
x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
|
136
|
+
} else {
|
137
|
+
var cont = $(opts.scrollContainer);
|
138
|
+
var offset = cont.offset();
|
139
|
+
y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
|
140
|
+
x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
|
141
|
+
}
|
142
|
+
|
143
|
+
list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
|
144
|
+
list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
|
145
|
+
|
146
|
+
this.draggedItem.css({ top: top, left: left });
|
147
|
+
},
|
148
|
+
|
149
|
+
wheel: function(e) {
|
150
|
+
if (($.browser.safari || $.browser.mozilla) && list && opts.scrollContainer != window) {
|
151
|
+
var cont = $(opts.scrollContainer);
|
152
|
+
var offset = cont.offset();
|
153
|
+
if (e.pageX > offset.left && e.pageX < offset.left + cont.width() && e.pageY > offset.top && e.pageY < offset.top + cont.height()) {
|
154
|
+
var delta = e.detail ? e.detail * 5 : e.wheelDelta / -2;
|
155
|
+
cont.scrollTop(cont.scrollTop() + delta);
|
156
|
+
e.preventDefault();
|
157
|
+
}
|
158
|
+
}
|
159
|
+
},
|
160
|
+
|
161
|
+
buildPositionTable: function() {
|
162
|
+
var item = this.draggedItem == null ? null : this.draggedItem.get(0);
|
163
|
+
var pos = [];
|
164
|
+
$(this.container).children(opts.itemSelector).each(function(i, elm) {
|
165
|
+
if (elm != item) {
|
166
|
+
var loc = $(elm).offset();
|
167
|
+
loc.right = loc.left + $(elm).width();
|
168
|
+
loc.bottom = loc.top + $(elm).height();
|
169
|
+
loc.elm = elm;
|
170
|
+
pos.push(loc);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
this.pos = pos;
|
174
|
+
},
|
175
|
+
|
176
|
+
dropItem: function() {
|
177
|
+
if (list.draggedItem == null)
|
178
|
+
return;
|
179
|
+
|
180
|
+
$(list.container).find(opts.dragSelector).css("cursor", "pointer");
|
181
|
+
list.placeHolderItem.before(list.draggedItem);
|
182
|
+
|
183
|
+
var orig = list.draggedItem.attr("data-origStyle");
|
184
|
+
if (orig == "")
|
185
|
+
list.draggedItem.removeAttr("style");
|
186
|
+
else
|
187
|
+
list.draggedItem.attr("style", orig);
|
188
|
+
list.draggedItem.removeAttr("data-origStyle");
|
189
|
+
list.placeHolderItem.remove();
|
190
|
+
|
191
|
+
$("[data-dropTarget]").remove();
|
192
|
+
|
193
|
+
window.clearInterval(list.scroll.scrollY);
|
194
|
+
window.clearInterval(list.scroll.scrollX);
|
195
|
+
|
196
|
+
var changed = false;
|
197
|
+
$(lists).each(function() {
|
198
|
+
$(this.container).children(opts.itemSelector).each(function(j) {
|
199
|
+
if (parseInt($(this).attr("data-itemIdx")) != j) {
|
200
|
+
changed = true;
|
201
|
+
$(this).attr("data-itemIdx", j);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
});
|
205
|
+
if (changed)
|
206
|
+
opts.dragEnd.apply(list.draggedItem);
|
207
|
+
list.draggedItem = null;
|
208
|
+
$(document).unbind("selectstart", list.stopBubble);
|
209
|
+
$(document).unbind("mousemove", list.swapItems);
|
210
|
+
$(document).unbind("mouseup", list.dropItem);
|
211
|
+
if (opts.scrollContainer != window)
|
212
|
+
$(window).unbind("DOMMouseScroll mousewheel", list.wheel);
|
213
|
+
return false;
|
214
|
+
},
|
215
|
+
|
216
|
+
stopBubble: function() { return false; },
|
217
|
+
|
218
|
+
swapItems: function(e) {
|
219
|
+
if (list.draggedItem == null)
|
220
|
+
return false;
|
221
|
+
|
222
|
+
list.setPos(e.pageX, e.pageY);
|
223
|
+
|
224
|
+
var ei = list.findPos(e.pageX, e.pageY);
|
225
|
+
var nlist = list;
|
226
|
+
for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
|
227
|
+
ei = lists[i].findPos(e.pageX, e.pageY);
|
228
|
+
nlist = lists[i];
|
229
|
+
}
|
230
|
+
|
231
|
+
if (ei == -1 || $(nlist.pos[ei].elm).attr("data-placeHolder"))
|
232
|
+
return false;
|
233
|
+
|
234
|
+
if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
|
235
|
+
$(nlist.pos[ei].elm).before(list.placeHolderItem);
|
236
|
+
else
|
237
|
+
$(nlist.pos[ei].elm).after(list.placeHolderItem);
|
238
|
+
|
239
|
+
$(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
|
240
|
+
lastPos = list.draggedItem.offset();
|
241
|
+
return false;
|
242
|
+
},
|
243
|
+
|
244
|
+
findPos: function(x, y) {
|
245
|
+
for (var i = 0; i < this.pos.length; i++) {
|
246
|
+
if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
|
247
|
+
return i;
|
248
|
+
}
|
249
|
+
return -1;
|
250
|
+
},
|
251
|
+
|
252
|
+
createDropTargets: function() {
|
253
|
+
if (!opts.dragBetween)
|
254
|
+
return;
|
255
|
+
|
256
|
+
$(lists).each(function() {
|
257
|
+
var ph = $(this.container).find("[data-placeHolder]");
|
258
|
+
var dt = $(this.container).find("[data-dropTarget]");
|
259
|
+
if (ph.size() > 0 && dt.size() > 0)
|
260
|
+
dt.remove();
|
261
|
+
else if (ph.size() == 0 && dt.size() == 0) {
|
262
|
+
//list.placeHolderItem.clone().removeAttr("data-placeHolder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
|
263
|
+
$(this.container).append(list.placeHolderItem.removeAttr("data-placeHolder").clone().attr("data-dropTarget", true));
|
264
|
+
list.placeHolderItem.attr("data-placeHolder", true);
|
265
|
+
}
|
266
|
+
});
|
267
|
+
}
|
268
|
+
};
|
269
|
+
|
270
|
+
newList.init();
|
271
|
+
lists.push(newList);
|
272
|
+
});
|
273
|
+
|
274
|
+
return this;
|
275
|
+
};
|
276
|
+
|
277
|
+
$.fn.slidedragsort.defaults = {
|
278
|
+
itemSelector: ".item",
|
279
|
+
dragSelector: ".item",
|
280
|
+
dragSelectorExclude: "input, textarea, a[href]",
|
281
|
+
dragEnd: function() { },
|
282
|
+
dragBetween: false,
|
283
|
+
placeHolderTemplate: "<div class=\"item\"> </div>",
|
284
|
+
scrollContainer: window,
|
285
|
+
scrollSpeed: 5
|
286
|
+
};
|
287
|
+
|
288
|
+
})(jQuery);
|
@@ -0,0 +1,98 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Serialize List
|
3
|
+
* Copyright (c) 2009 Mike Botsko, Botsko.net LLC
|
4
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
5
|
+
* Copyright notice and license must remain intact for legal use
|
6
|
+
* Version .2
|
7
|
+
*
|
8
|
+
* Serialize an unordered or ordered list item. Optional ability
|
9
|
+
* to determine which attributes are included. The serialization
|
10
|
+
* will be read by PHP as a multidimensional array which you may
|
11
|
+
* use for saving state.
|
12
|
+
*
|
13
|
+
* http://github.com/botskonet/jquery.serialize-list
|
14
|
+
*/
|
15
|
+
(function($){
|
16
|
+
$.fn.serializeSlidelist = function(options) {
|
17
|
+
// Extend the configuration options with user-provided
|
18
|
+
var defaults = {
|
19
|
+
attributes: ['id'], // which html attributes should be sent?
|
20
|
+
text: false,
|
21
|
+
allow_nest: false, // allow nested elements to be included
|
22
|
+
prepend: 'slides', // which query string param name should be used?
|
23
|
+
att_regex: false, // replacement regex to run on attr values
|
24
|
+
is_child: false // determine if we're serializing a child list
|
25
|
+
};
|
26
|
+
var opts = $.extend(defaults, options);
|
27
|
+
var serialStr = '';
|
28
|
+
if(!opts.is_child){
|
29
|
+
opts.prepend = '&'+opts.prepend;
|
30
|
+
}
|
31
|
+
// Begin the core plugin
|
32
|
+
this.each(function() {
|
33
|
+
var li_count = 0;
|
34
|
+
$(this).children().each(function(index, li){
|
35
|
+
if(opts.allow_nest || opts.attributes.length > 1){
|
36
|
+
for(att in opts.attributes){
|
37
|
+
val = att_rep(opts.attributes[att], $(this).attr(opts.attributes[att]));
|
38
|
+
if (val != undefined) serialStr += opts.prepend+'['+li_count+']['+opts.attributes[att]+']='+val;
|
39
|
+
if ($(li).children().size() > 1) {
|
40
|
+
serialStr += opts.prepend+'['+li_count+'][text]='+$(li)[0].firstChild.textContent;
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
if (opts.text) {
|
44
|
+
if (opts.attributes[att] == 'id') {
|
45
|
+
serialStr += opts.prepend+'['+li_count+'][text]='+$(this).text();
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
val = att_rep(opts.attributes[0], $(this).attr(opts.attributes[0]));
|
52
|
+
if (val != undefined) serialStr += opts.prepend+'['+li_count+']='+val;
|
53
|
+
if ($(li).children().size() > 1) {
|
54
|
+
if (opts.text) {
|
55
|
+
if (opts.attributes[att] == 'id') {
|
56
|
+
serialStr += opts.prepend+'['+li_count+'][text]='+$(li)[0].firstChild.textContent;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
if (opts.text) {
|
62
|
+
if (opts.attributes[att] == 'id') {
|
63
|
+
serialStr += opts.prepend+'['+li_count+'][text]='+$(this).text();
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
// append any children elements
|
69
|
+
if(opts.allow_nest){
|
70
|
+
var child_base = opts.prepend+'['+li_count+'][children]';
|
71
|
+
$(this).children().each(function(){
|
72
|
+
if(this.tagName == 'UL' || this.tagName == 'OL'){
|
73
|
+
serialStr += $(this).serializelist({
|
74
|
+
'prepend': child_base,
|
75
|
+
'is_child': true,
|
76
|
+
'attributes':opts.attributes
|
77
|
+
});
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}
|
81
|
+
li_count++;
|
82
|
+
});
|
83
|
+
function att_rep (att, val){
|
84
|
+
if(opts.att_regex){
|
85
|
+
for(x in opts.att_regex){
|
86
|
+
if(opts.att_regex[x].att == att){
|
87
|
+
return val.replace(opts.att_regex[x].regex, '');
|
88
|
+
}
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
return val;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
});
|
95
|
+
return(serialStr);
|
96
|
+
};
|
97
|
+
})(jQuery);
|
98
|
+
|