transit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +19 -11
- data/app/assets/images/transit/icon24x24.png +0 -0
- data/app/assets/images/transit/icon24x24_files.png +0 -0
- data/app/assets/images/transit/jplayer.swf +0 -0
- data/app/assets/images/transit/uploadify.swf +0 -0
- data/app/assets/images/transit/video_player.swf +0 -0
- data/app/assets/javascripts/jqtools/expose.js +224 -0
- data/app/assets/javascripts/jqtools/flashembed.js +300 -0
- data/app/assets/javascripts/jqtools/overlay.js +294 -0
- data/app/assets/javascripts/jqtools/scrollable.js +3 -0
- data/app/assets/javascripts/jqtools/scrollable/autoscroll.js +81 -0
- data/app/assets/javascripts/jqtools/scrollable/base.js +335 -0
- data/app/assets/javascripts/jqtools/scrollable/navigator.js +139 -0
- data/app/assets/javascripts/jqtools/validator.js +590 -0
- data/app/assets/javascripts/jqueryui/accordion.js +611 -0
- data/app/assets/javascripts/jqueryui/autocomplete.js +612 -0
- data/app/assets/javascripts/jqueryui/button.js +388 -0
- data/app/assets/javascripts/jqueryui/core.js +312 -0
- data/app/assets/javascripts/jqueryui/datepicker.js +1791 -0
- data/app/assets/javascripts/jqueryui/dialog.js +878 -0
- data/app/assets/javascripts/jqueryui/draggable.js +815 -0
- data/app/assets/javascripts/jqueryui/droppable.js +285 -0
- data/app/assets/javascripts/jqueryui/effects/blind.js +49 -0
- data/app/assets/javascripts/jqueryui/effects/bounce.js +78 -0
- data/app/assets/javascripts/jqueryui/effects/clip.js +54 -0
- data/app/assets/javascripts/jqueryui/effects/core.js +746 -0
- data/app/assets/javascripts/jqueryui/effects/drop.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/explode.js +79 -0
- data/app/assets/javascripts/jqueryui/effects/fade.js +32 -0
- data/app/assets/javascripts/jqueryui/effects/fold.js +56 -0
- data/app/assets/javascripts/jqueryui/effects/highlight.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/pulsate.js +51 -0
- data/app/assets/javascripts/jqueryui/effects/scale.js +178 -0
- data/app/assets/javascripts/jqueryui/effects/shake.js +57 -0
- data/app/assets/javascripts/jqueryui/effects/slide.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/transfer.js +45 -0
- data/app/assets/javascripts/jqueryui/mouse.js +160 -0
- data/app/assets/javascripts/jqueryui/position.js +252 -0
- data/app/assets/javascripts/jqueryui/progressbar.js +109 -0
- data/app/assets/javascripts/jqueryui/resizable.js +814 -0
- data/app/assets/javascripts/jqueryui/selectable.js +266 -0
- data/app/assets/javascripts/jqueryui/slider.js +666 -0
- data/app/assets/javascripts/jqueryui/sortable.js +1077 -0
- data/app/assets/javascripts/jqueryui/tabs.js +758 -0
- data/app/assets/javascripts/jqueryui/widget.js +262 -0
- data/app/assets/javascripts/libs/backbone.js +1152 -0
- data/app/assets/javascripts/libs/cookie.js +89 -0
- data/app/assets/javascripts/libs/fileinput.js +130 -0
- data/app/assets/javascripts/libs/jplayer.js +1768 -0
- data/app/assets/javascripts/libs/proper.js +541 -0
- data/app/assets/javascripts/libs/sanitize.js +282 -0
- data/app/assets/javascripts/libs/selecttolist.js +75 -0
- data/app/assets/javascripts/libs/underscore.js +807 -0
- data/app/assets/javascripts/libs/uploadify.js +677 -0
- data/app/assets/javascripts/libs/wymeditor.js +9538 -0
- data/app/assets/javascripts/transit.js +4 -0
- data/app/assets/javascripts/transit/admin.js +22 -0
- data/app/assets/javascripts/transit/admin/contexts.js +52 -0
- data/app/assets/javascripts/transit/admin/fields.js +36 -0
- data/app/assets/javascripts/transit/admin/upload.js +109 -0
- data/app/assets/javascripts/transit/config.js.erb +101 -0
- data/app/assets/javascripts/transit/contexts/audio.js +39 -0
- data/app/assets/javascripts/transit/contexts/video.js +79 -0
- data/app/assets/javascripts/transit/core.js +171 -0
- data/app/assets/javascripts/transit/frontend.js +3 -0
- data/app/assets/javascripts/transit/lib/base64.js +120 -0
- data/app/assets/javascripts/transit/lib/editor.js +177 -0
- data/app/assets/javascripts/transit/views/audio_player.jst +22 -0
- data/app/assets/javascripts/transit/views/editor_toolbar.jst +12 -0
- data/app/assets/javascripts/transit/views/file_upload.jst +5 -0
- data/app/assets/javascripts/transit/views/video_player.jst +20 -0
- data/app/assets/javascripts/transit/views/wym_box.jst +4 -0
- data/app/assets/javascripts/transit/views/wym_iframe.jst +3 -0
- data/app/assets/stylesheets/transit.css.scss.erb +42 -0
- data/app/assets/stylesheets/transit/forms.css.scss +66 -0
- data/app/assets/stylesheets/transit/media/audio.css.scss +65 -0
- data/app/assets/stylesheets/transit/media/video.css.scss +30 -0
- data/app/assets/stylesheets/transit/panel.css.scss +100 -0
- data/app/assets/stylesheets/transit/ui.css.scss +507 -0
- data/app/controllers/pages_controller.rb +3 -0
- data/app/controllers/posts_controller.rb +3 -0
- data/app/controllers/transit/assets_controller.rb +38 -0
- data/app/controllers/transit/contexts_controller.rb +12 -9
- data/app/controllers/transit/pages_controller.rb +26 -0
- data/app/controllers/transit/posts_controller.rb +31 -0
- data/app/controllers/transit/topics_controller.rb +5 -0
- data/app/controllers/transit_controller.rb +16 -0
- data/app/helpers/transit/admin_helper.rb +43 -0
- data/app/helpers/transit/form_helper.rb +17 -0
- data/app/helpers/transit/package_helper.rb +41 -0
- data/app/helpers/transit/pagination_helper.rb +58 -0
- data/app/helpers/transit_helper.rb +42 -0
- data/app/models/comment.rb +37 -0
- data/app/models/contexts/audio.rb +12 -0
- data/app/models/{text.rb → contexts/text.rb} +0 -0
- data/app/models/contexts/video.rb +24 -0
- data/app/models/topic.rb +19 -0
- data/app/models/transit/asset.rb +68 -0
- data/{lib → app/models}/transit/context.rb +29 -0
- data/app/views/contexts/_text.html.erb +1 -1
- data/app/views/posts/index.rss.builder +18 -0
- data/app/views/transit/assets/_file.html.erb +4 -0
- data/app/views/transit/assets/_image.html.erb +13 -0
- data/app/views/transit/assets/create.js.erb +8 -0
- data/app/views/transit/assets/destroy.js.erb +3 -0
- data/app/views/transit/assets/manage.html.erb +20 -0
- data/app/views/transit/contexts/_audio.html.erb +18 -0
- data/app/views/transit/contexts/_text.html.erb +6 -0
- data/app/views/transit/contexts/_video.html.erb +13 -0
- data/app/views/transit/contexts/destroy.js.erb +1 -0
- data/app/views/transit/contexts/index.html.erb +5 -0
- data/app/views/transit/contexts/new.js.erb +7 -0
- data/app/views/transit/contexts/show.html.erb +8 -0
- data/app/views/transit/index.html.erb +26 -0
- data/app/views/transit/index.js.erb +1 -0
- data/app/views/transit/interface/post_panel.html.erb +96 -0
- data/app/views/transit/pages/_table.html.erb +7 -0
- data/app/views/transit/pages/edit.html.erb +17 -0
- data/app/views/transit/pages/index.html.erb +17 -0
- data/app/views/transit/pages/update.js.erb +1 -0
- data/app/views/transit/posts/_form.html.erb +49 -0
- data/app/views/transit/posts/edit.html.erb +14 -0
- data/app/views/transit/posts/new.html.erb +21 -0
- data/app/views/transit/table.html.erb +13 -0
- data/app/views/transit/table.js.erb +8 -0
- data/app/views/transit/topics/manage.html.erb +28 -0
- data/config/locales/en.yml +22 -0
- data/config/routes.rb +3 -3
- data/lib/transit.rb +51 -17
- data/lib/transit/admin.rb +85 -0
- data/lib/transit/builders/form_builder.rb +319 -0
- data/lib/transit/builders/jst_builder.rb +38 -0
- data/lib/transit/builders/package_builder.rb +45 -0
- data/lib/transit/config.rb +20 -0
- data/lib/transit/controller/generator.rb +42 -0
- data/lib/transit/controller/responder.rb +34 -0
- data/lib/transit/core_ext.rb +18 -0
- data/lib/transit/errors/resource_not_found.rb +6 -0
- data/lib/transit/model/assets.rb +14 -0
- data/lib/transit/model/attachments.rb +55 -0
- data/lib/transit/model/auto_increment.rb +22 -0
- data/lib/transit/model/base.rb +56 -0
- data/lib/transit/model/comments.rb +19 -0
- data/lib/transit/model/hooks.rb +38 -0
- data/lib/transit/model/owners.rb +14 -0
- data/lib/transit/model/paginator.rb +92 -0
- data/lib/transit/model/topics.rb +14 -0
- data/lib/transit/package/page.rb +20 -12
- data/lib/transit/package/post.rb +87 -33
- data/lib/transit/package/post/validations.rb +14 -0
- data/lib/transit/rails/engine.rb +29 -13
- data/lib/transit/rails/railtie.rb +31 -0
- data/lib/transit/rails/routing.rb +11 -6
- data/lib/transit/services.rb +13 -0
- data/lib/transit/services/base.rb +14 -0
- data/lib/transit/services/facebook.rb +13 -0
- data/lib/transit/services/ted.rb +10 -0
- data/lib/transit/services/twitter.rb +13 -0
- data/lib/transit/services/vimeo.rb +10 -0
- data/lib/transit/services/you_tube.rb +12 -0
- data/lib/transit/version.rb +1 -1
- metadata +178 -31
- data/app/assets/stylesheets/includes/_compat.scss +0 -24
- data/app/assets/stylesheets/includes/_defaults.scss +0 -99
- data/app/assets/stylesheets/includes/_global.scss +0 -16
- data/app/assets/stylesheets/includes/_imports.scss +0 -27
- data/app/assets/stylesheets/includes/_mixins.scss +0 -38
- data/app/assets/stylesheets/includes/_setup.scss +0 -85
- data/app/assets/stylesheets/layout.css.scss +0 -29
- data/app/assets/stylesheets/transit.css +0 -3
- data/app/controllers/application_controller.rb +0 -5
- data/app/controllers/transit/index_controller.rb +0 -7
- data/app/controllers/transit/packages_controller.rb +0 -64
- data/app/controllers/transit/transit_controller.rb +0 -4
- data/app/helpers/routing_helpers.rb +0 -7
- data/app/models/audio.rb +0 -4
- data/app/models/package_asset.rb +0 -11
- data/app/models/video.rb +0 -8
- data/app/views/contexts/_audio.html.erb +0 -1
- data/app/views/contexts/_video.html.erb +0 -1
- data/app/views/layouts/transit.html.erb +0 -31
- data/app/views/transit/index/index.html.erb +0 -0
- data/lib/transit/helpers/controller_helpers.rb +0 -40
- data/lib/transit/helpers/model_helpers.rb +0 -26
- data/lib/transit/package.rb +0 -25
- data/lib/transit/package/base.rb +0 -49
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem 'rails', '3.1.0.rc4'
|
4
4
|
gem "rspec-rails"
|
5
5
|
gem 'mongoid-rspec'
|
6
6
|
gem 'mongo', '~> 1.3'
|
@@ -9,16 +9,24 @@ gem 'mongoid', '~> 2.0'
|
|
9
9
|
gem "devise", "~> 1.3"
|
10
10
|
gem "paperclip", "~> 2.3"
|
11
11
|
gem 'rack-raw-upload', '0.1.1'
|
12
|
-
gem
|
13
|
-
gem "
|
12
|
+
gem "motr", "0.1.1"
|
13
|
+
gem "paperclip", "~> 2.3"
|
14
|
+
gem 'sass-rails'
|
15
|
+
gem 'inherited_resources', '1.2.2'
|
16
|
+
|
17
|
+
gem "mongrel",'1.2.0.pre2'
|
18
|
+
gem 'compass', :git => "https://github.com/chriseppstein/compass.git", :branch => "rails31"
|
14
19
|
|
15
20
|
group :test do
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem '
|
19
|
-
gem '
|
20
|
-
gem
|
21
|
-
gem '
|
21
|
+
gem 'spork', '~> 0.9.0.rc', :require => false
|
22
|
+
gem "mocha","0.9.12", :require => false
|
23
|
+
gem 'ffaker', :require => false
|
24
|
+
gem 'mongoid-rspec', :require => false
|
25
|
+
gem "capybara", ">= 0.4.0", :require => false
|
26
|
+
gem 'guard', :require => false
|
27
|
+
gem 'guard-rspec', :require => false
|
28
|
+
gem 'growl', '1.0.3', :require => false
|
22
29
|
gem "capybara", ">= 0.4.0"
|
23
|
-
|
24
|
-
|
30
|
+
gem "fabrication"
|
31
|
+
gem 'rspec-rails-mocha', '0.3.0', :require => false
|
32
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,224 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* jQuery Tools @VERSION / Expose - Dim the lights
|
4
|
+
*
|
5
|
+
* NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
|
6
|
+
*
|
7
|
+
* http://flowplayer.org/tools/toolbox/expose.html
|
8
|
+
*
|
9
|
+
* Since: Mar 2010
|
10
|
+
* Date: @DATE
|
11
|
+
*/
|
12
|
+
(function($) {
|
13
|
+
|
14
|
+
// static constructs
|
15
|
+
$.tools = $.tools || {version: '@VERSION'};
|
16
|
+
|
17
|
+
var tool;
|
18
|
+
|
19
|
+
tool = $.tools.expose = {
|
20
|
+
|
21
|
+
conf: {
|
22
|
+
maskId: 'exposeMask',
|
23
|
+
loadSpeed: 'slow',
|
24
|
+
closeSpeed: 'fast',
|
25
|
+
closeOnClick: true,
|
26
|
+
closeOnEsc: true,
|
27
|
+
|
28
|
+
// css settings
|
29
|
+
zIndex: 9998,
|
30
|
+
opacity: 0.8,
|
31
|
+
startOpacity: 0,
|
32
|
+
color: '#fff',
|
33
|
+
|
34
|
+
// callbacks
|
35
|
+
onLoad: null,
|
36
|
+
onClose: null
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
/* one of the greatest headaches in the tool. finally made it */
|
41
|
+
function viewport() {
|
42
|
+
|
43
|
+
// the horror case
|
44
|
+
if ($.browser.msie) {
|
45
|
+
|
46
|
+
// if there are no scrollbars then use window.height
|
47
|
+
var d = $(document).height(), w = $(window).height();
|
48
|
+
|
49
|
+
return [
|
50
|
+
window.innerWidth || // ie7+
|
51
|
+
document.documentElement.clientWidth || // ie6
|
52
|
+
document.body.clientWidth, // ie6 quirks mode
|
53
|
+
d - w < 20 ? w : d
|
54
|
+
];
|
55
|
+
}
|
56
|
+
|
57
|
+
// other well behaving browsers
|
58
|
+
return [$(document).width(), $(document).height()];
|
59
|
+
}
|
60
|
+
|
61
|
+
function call(fn) {
|
62
|
+
if (fn) { return fn.call($.mask); }
|
63
|
+
}
|
64
|
+
|
65
|
+
var mask, exposed, loaded, config, overlayIndex;
|
66
|
+
|
67
|
+
|
68
|
+
$.mask = {
|
69
|
+
|
70
|
+
load: function(conf, els) {
|
71
|
+
|
72
|
+
// already loaded ?
|
73
|
+
if (loaded) { return this; }
|
74
|
+
|
75
|
+
// configuration
|
76
|
+
if (typeof conf == 'string') {
|
77
|
+
conf = {color: conf};
|
78
|
+
}
|
79
|
+
|
80
|
+
// use latest config
|
81
|
+
conf = conf || config;
|
82
|
+
|
83
|
+
config = conf = $.extend($.extend({}, tool.conf), conf);
|
84
|
+
|
85
|
+
// get the mask
|
86
|
+
mask = $("#" + conf.maskId);
|
87
|
+
|
88
|
+
// or create it
|
89
|
+
if (!mask.length) {
|
90
|
+
mask = $('<div/>').attr("id", conf.maskId);
|
91
|
+
$("body").append(mask);
|
92
|
+
}
|
93
|
+
|
94
|
+
// set position and dimensions
|
95
|
+
var size = viewport();
|
96
|
+
|
97
|
+
mask.css({
|
98
|
+
position:'absolute',
|
99
|
+
top: 0,
|
100
|
+
left: 0,
|
101
|
+
width: size[0],
|
102
|
+
height: size[1],
|
103
|
+
display: 'none',
|
104
|
+
opacity: conf.startOpacity,
|
105
|
+
zIndex: conf.zIndex
|
106
|
+
});
|
107
|
+
|
108
|
+
if (conf.color) {
|
109
|
+
mask.css("backgroundColor", conf.color);
|
110
|
+
}
|
111
|
+
|
112
|
+
// onBeforeLoad
|
113
|
+
if (call(conf.onBeforeLoad) === false) {
|
114
|
+
return this;
|
115
|
+
}
|
116
|
+
|
117
|
+
// esc button
|
118
|
+
if (conf.closeOnEsc) {
|
119
|
+
$(document).bind("keydown.mask", function(e) {
|
120
|
+
if (e.keyCode == 27) {
|
121
|
+
$.mask.close(e);
|
122
|
+
}
|
123
|
+
});
|
124
|
+
}
|
125
|
+
|
126
|
+
// mask click closes
|
127
|
+
if (conf.closeOnClick) {
|
128
|
+
mask.bind("click.mask", function(e) {
|
129
|
+
$.mask.close(e);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
// resize mask when window is resized
|
134
|
+
$(window).bind("resize.mask", function() {
|
135
|
+
$.mask.fit();
|
136
|
+
});
|
137
|
+
|
138
|
+
// exposed elements
|
139
|
+
if (els && els.length) {
|
140
|
+
|
141
|
+
overlayIndex = els.eq(0).css("zIndex");
|
142
|
+
|
143
|
+
// make sure element is positioned absolutely or relatively
|
144
|
+
$.each(els, function() {
|
145
|
+
var el = $(this);
|
146
|
+
if (!/relative|absolute|fixed/i.test(el.css("position"))) {
|
147
|
+
el.css("position", "relative");
|
148
|
+
}
|
149
|
+
});
|
150
|
+
|
151
|
+
// make elements sit on top of the mask
|
152
|
+
exposed = els.css({ zIndex: Math.max(conf.zIndex + 1, overlayIndex == 'auto' ? 0 : overlayIndex)});
|
153
|
+
}
|
154
|
+
|
155
|
+
// reveal mask
|
156
|
+
mask.css({display: 'block'}).fadeTo(conf.loadSpeed, conf.opacity, function() {
|
157
|
+
$.mask.fit();
|
158
|
+
call(conf.onLoad);
|
159
|
+
loaded = "full";
|
160
|
+
});
|
161
|
+
|
162
|
+
loaded = true;
|
163
|
+
return this;
|
164
|
+
},
|
165
|
+
|
166
|
+
close: function() {
|
167
|
+
if (loaded) {
|
168
|
+
|
169
|
+
// onBeforeClose
|
170
|
+
if (call(config.onBeforeClose) === false) { return this; }
|
171
|
+
|
172
|
+
mask.fadeOut(config.closeSpeed, function() {
|
173
|
+
call(config.onClose);
|
174
|
+
if (exposed) {
|
175
|
+
exposed.css({zIndex: overlayIndex});
|
176
|
+
}
|
177
|
+
loaded = false;
|
178
|
+
});
|
179
|
+
|
180
|
+
// unbind various event listeners
|
181
|
+
$(document).unbind("keydown.mask");
|
182
|
+
mask.unbind("click.mask");
|
183
|
+
$(window).unbind("resize.mask");
|
184
|
+
}
|
185
|
+
|
186
|
+
return this;
|
187
|
+
},
|
188
|
+
|
189
|
+
fit: function() {
|
190
|
+
if (loaded) {
|
191
|
+
var size = viewport();
|
192
|
+
mask.css({width: size[0], height: size[1]});
|
193
|
+
}
|
194
|
+
},
|
195
|
+
|
196
|
+
getMask: function() {
|
197
|
+
return mask;
|
198
|
+
},
|
199
|
+
|
200
|
+
isLoaded: function(fully) {
|
201
|
+
return fully ? loaded == 'full' : loaded;
|
202
|
+
},
|
203
|
+
|
204
|
+
getConf: function() {
|
205
|
+
return config;
|
206
|
+
},
|
207
|
+
|
208
|
+
getExposed: function() {
|
209
|
+
return exposed;
|
210
|
+
}
|
211
|
+
};
|
212
|
+
|
213
|
+
$.fn.mask = function(conf) {
|
214
|
+
$.mask.load(conf);
|
215
|
+
return this;
|
216
|
+
};
|
217
|
+
|
218
|
+
$.fn.expose = function(conf) {
|
219
|
+
$.mask.load(conf, this);
|
220
|
+
return this;
|
221
|
+
};
|
222
|
+
|
223
|
+
|
224
|
+
})(jQuery);
|
@@ -0,0 +1,300 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* jQuery Tools @VERSION / Flashembed - New wave Flash embedding
|
4
|
+
*
|
5
|
+
* NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
|
6
|
+
*
|
7
|
+
* http://flowplayer.org/tools/toolbox/flashembed.html
|
8
|
+
*
|
9
|
+
* Since : March 2008
|
10
|
+
* Date : @DATE
|
11
|
+
*/
|
12
|
+
(function() {
|
13
|
+
|
14
|
+
var IE = document.all,
|
15
|
+
URL = 'http://www.adobe.com/go/getflashplayer',
|
16
|
+
JQUERY = typeof jQuery == 'function',
|
17
|
+
RE = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/,
|
18
|
+
GLOBAL_OPTS = {
|
19
|
+
// very common opts
|
20
|
+
width: '100%',
|
21
|
+
height: '100%',
|
22
|
+
id: "_" + ("" + Math.random()).slice(9),
|
23
|
+
|
24
|
+
// flashembed defaults
|
25
|
+
allowfullscreen: true,
|
26
|
+
allowscriptaccess: 'always',
|
27
|
+
quality: 'high',
|
28
|
+
|
29
|
+
// flashembed specific options
|
30
|
+
version: [3, 0],
|
31
|
+
onFail: null,
|
32
|
+
expressInstall: null,
|
33
|
+
w3c: false,
|
34
|
+
cachebusting: false
|
35
|
+
};
|
36
|
+
|
37
|
+
// version 9 bugfix: (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
|
38
|
+
if (window.attachEvent) {
|
39
|
+
window.attachEvent("onbeforeunload", function() {
|
40
|
+
__flash_unloadHandler = function() {};
|
41
|
+
__flash_savedUnloadHandler = function() {};
|
42
|
+
});
|
43
|
+
}
|
44
|
+
|
45
|
+
// simple extend
|
46
|
+
function extend(to, from) {
|
47
|
+
if (from) {
|
48
|
+
for (var key in from) {
|
49
|
+
if (from.hasOwnProperty(key)) {
|
50
|
+
to[key] = from[key];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return to;
|
55
|
+
}
|
56
|
+
|
57
|
+
// used by asString method
|
58
|
+
function map(arr, func) {
|
59
|
+
var newArr = [];
|
60
|
+
for (var i in arr) {
|
61
|
+
if (arr.hasOwnProperty(i)) {
|
62
|
+
newArr[i] = func(arr[i]);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return newArr;
|
66
|
+
}
|
67
|
+
|
68
|
+
window.flashembed = function(root, opts, conf) {
|
69
|
+
|
70
|
+
// root must be found / loaded
|
71
|
+
if (typeof root == 'string') {
|
72
|
+
root = document.getElementById(root.replace("#", ""));
|
73
|
+
}
|
74
|
+
|
75
|
+
// not found
|
76
|
+
if (!root) { return; }
|
77
|
+
|
78
|
+
if (typeof opts == 'string') {
|
79
|
+
opts = {src: opts};
|
80
|
+
}
|
81
|
+
|
82
|
+
return new Flash(root, extend(extend({}, GLOBAL_OPTS), opts), conf);
|
83
|
+
};
|
84
|
+
|
85
|
+
// flashembed "static" API
|
86
|
+
var f = extend(window.flashembed, {
|
87
|
+
|
88
|
+
conf: GLOBAL_OPTS,
|
89
|
+
|
90
|
+
getVersion: function() {
|
91
|
+
var fo, ver;
|
92
|
+
|
93
|
+
try {
|
94
|
+
ver = navigator.plugins["Shockwave Flash"].description.slice(16);
|
95
|
+
} catch(e) {
|
96
|
+
|
97
|
+
try {
|
98
|
+
fo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
|
99
|
+
ver = fo && fo.GetVariable("$version");
|
100
|
+
|
101
|
+
} catch(err) {
|
102
|
+
try {
|
103
|
+
fo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
|
104
|
+
ver = fo && fo.GetVariable("$version");
|
105
|
+
} catch(err2) { }
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
ver = RE.exec(ver);
|
110
|
+
return ver ? [ver[1], ver[3]] : [0, 0];
|
111
|
+
},
|
112
|
+
|
113
|
+
asString: function(obj) {
|
114
|
+
|
115
|
+
if (obj === null || obj === undefined) { return null; }
|
116
|
+
var type = typeof obj;
|
117
|
+
if (type == 'object' && obj.push) { type = 'array'; }
|
118
|
+
|
119
|
+
switch (type){
|
120
|
+
|
121
|
+
case 'string':
|
122
|
+
obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1');
|
123
|
+
|
124
|
+
// flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit)
|
125
|
+
obj = obj.replace(/^\s?(\d+\.?\d+)%/, "$1pct");
|
126
|
+
return '"' +obj+ '"';
|
127
|
+
|
128
|
+
case 'array':
|
129
|
+
return '['+ map(obj, function(el) {
|
130
|
+
return f.asString(el);
|
131
|
+
}).join(',') +']';
|
132
|
+
|
133
|
+
case 'function':
|
134
|
+
return '"function()"';
|
135
|
+
|
136
|
+
case 'object':
|
137
|
+
var str = [];
|
138
|
+
for (var prop in obj) {
|
139
|
+
if (obj.hasOwnProperty(prop)) {
|
140
|
+
str.push('"'+prop+'":'+ f.asString(obj[prop]));
|
141
|
+
}
|
142
|
+
}
|
143
|
+
return '{'+str.join(',')+'}';
|
144
|
+
}
|
145
|
+
|
146
|
+
// replace ' --> " and remove spaces
|
147
|
+
return String(obj).replace(/\s/g, " ").replace(/\'/g, "\"");
|
148
|
+
},
|
149
|
+
|
150
|
+
getHTML: function(opts, conf) {
|
151
|
+
|
152
|
+
opts = extend({}, opts);
|
153
|
+
|
154
|
+
/******* OBJECT tag and it's attributes *******/
|
155
|
+
var html = '<object width="' + opts.width +
|
156
|
+
'" height="' + opts.height +
|
157
|
+
'" id="' + opts.id +
|
158
|
+
'" name="' + opts.id + '"';
|
159
|
+
|
160
|
+
if (opts.cachebusting) {
|
161
|
+
opts.src += ((opts.src.indexOf("?") != -1 ? "&" : "?") + Math.random());
|
162
|
+
}
|
163
|
+
|
164
|
+
if (opts.w3c || !IE) {
|
165
|
+
html += ' data="' +opts.src+ '" type="application/x-shockwave-flash"';
|
166
|
+
} else {
|
167
|
+
html += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
|
168
|
+
}
|
169
|
+
|
170
|
+
html += '>';
|
171
|
+
|
172
|
+
/******* nested PARAM tags *******/
|
173
|
+
if (opts.w3c || IE) {
|
174
|
+
html += '<param name="movie" value="' +opts.src+ '" />';
|
175
|
+
}
|
176
|
+
|
177
|
+
// not allowed params
|
178
|
+
opts.width = opts.height = opts.id = opts.w3c = opts.src = null;
|
179
|
+
opts.onFail = opts.version = opts.expressInstall = null;
|
180
|
+
|
181
|
+
for (var key in opts) {
|
182
|
+
if (opts[key]) {
|
183
|
+
html += '<param name="'+ key +'" value="'+ opts[key] +'" />';
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
/******* FLASHVARS *******/
|
188
|
+
var vars = "";
|
189
|
+
|
190
|
+
if (conf) {
|
191
|
+
for (var k in conf) {
|
192
|
+
if (conf[k]) {
|
193
|
+
var val = conf[k];
|
194
|
+
vars += k +'='+ (/function|object/.test(typeof val) ? f.asString(val) : val) + '&';
|
195
|
+
}
|
196
|
+
}
|
197
|
+
vars = vars.slice(0, -1);
|
198
|
+
html += '<param name="flashvars" value=\'' + vars + '\' />';
|
199
|
+
}
|
200
|
+
|
201
|
+
html += "</object>";
|
202
|
+
|
203
|
+
return html;
|
204
|
+
},
|
205
|
+
|
206
|
+
isSupported: function(ver) {
|
207
|
+
return VERSION[0] > ver[0] || VERSION[0] == ver[0] && VERSION[1] >= ver[1];
|
208
|
+
}
|
209
|
+
|
210
|
+
});
|
211
|
+
|
212
|
+
var VERSION = f.getVersion();
|
213
|
+
|
214
|
+
function Flash(root, opts, conf) {
|
215
|
+
|
216
|
+
// version is ok
|
217
|
+
if (f.isSupported(opts.version)) {
|
218
|
+
root.innerHTML = f.getHTML(opts, conf);
|
219
|
+
|
220
|
+
// express install
|
221
|
+
} else if (opts.expressInstall && f.isSupported([6, 65])) {
|
222
|
+
root.innerHTML = f.getHTML(extend(opts, {src: opts.expressInstall}), {
|
223
|
+
MMredirectURL: location.href,
|
224
|
+
MMplayerType: 'PlugIn',
|
225
|
+
MMdoctitle: document.title
|
226
|
+
});
|
227
|
+
|
228
|
+
} else {
|
229
|
+
|
230
|
+
// fail #2.1 custom content inside container
|
231
|
+
if (!root.innerHTML.replace(/\s/g, '')) {
|
232
|
+
root.innerHTML =
|
233
|
+
"<h2>Flash version " + opts.version + " or greater is required</h2>" +
|
234
|
+
"<h3>" +
|
235
|
+
(VERSION[0] > 0 ? "Your version is " + VERSION : "You have no flash plugin installed") +
|
236
|
+
"</h3>" +
|
237
|
+
|
238
|
+
(root.tagName == 'A' ? "<p>Click here to download latest version</p>" :
|
239
|
+
"<p>Download latest version from <a href='" + URL + "'>here</a></p>");
|
240
|
+
|
241
|
+
if (root.tagName == 'A') {
|
242
|
+
root.onclick = function() {
|
243
|
+
location.href = URL;
|
244
|
+
};
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
// onFail
|
249
|
+
if (opts.onFail) {
|
250
|
+
var ret = opts.onFail.call(this);
|
251
|
+
if (typeof ret == 'string') { root.innerHTML = ret; }
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
// http://flowplayer.org/forum/8/18186#post-18593
|
256
|
+
if (IE) {
|
257
|
+
window[opts.id] = document.getElementById(opts.id);
|
258
|
+
}
|
259
|
+
|
260
|
+
// API methods for callback
|
261
|
+
extend(this, {
|
262
|
+
|
263
|
+
getRoot: function() {
|
264
|
+
return root;
|
265
|
+
},
|
266
|
+
|
267
|
+
getOptions: function() {
|
268
|
+
return opts;
|
269
|
+
},
|
270
|
+
|
271
|
+
|
272
|
+
getConf: function() {
|
273
|
+
return conf;
|
274
|
+
},
|
275
|
+
|
276
|
+
getApi: function() {
|
277
|
+
return root.firstChild;
|
278
|
+
}
|
279
|
+
|
280
|
+
});
|
281
|
+
}
|
282
|
+
|
283
|
+
// setup jquery support
|
284
|
+
if (JQUERY) {
|
285
|
+
|
286
|
+
// tools version number
|
287
|
+
jQuery.tools = jQuery.tools || {version: '@VERSION'};
|
288
|
+
|
289
|
+
jQuery.tools.flashembed = {
|
290
|
+
conf: GLOBAL_OPTS
|
291
|
+
};
|
292
|
+
|
293
|
+
jQuery.fn.flashembed = function(opts, conf) {
|
294
|
+
return this.each(function() {
|
295
|
+
$(this).data("flashembed", flashembed(this, opts, conf));
|
296
|
+
});
|
297
|
+
};
|
298
|
+
}
|
299
|
+
|
300
|
+
})();
|