slices 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +51 -0
- data/Rakefile +9 -0
- data/app/assets/images/slices/ajax-loader.gif +0 -0
- data/app/assets/images/slices/asset-background.png +0 -0
- data/app/assets/images/slices/asset-spinner.gif +0 -0
- data/app/assets/images/slices/bg_header.gif +0 -0
- data/app/assets/images/slices/black-Linen.png +0 -0
- data/app/assets/images/slices/calendar.svg +68 -0
- data/app/assets/images/slices/chosen-sprite.png +0 -0
- data/app/assets/images/slices/drag-handle.svg +9 -0
- data/app/assets/images/slices/icon_admins.png +0 -0
- data/app/assets/images/slices/icon_app.png +0 -0
- data/app/assets/images/slices/icon_assets.png +0 -0
- data/app/assets/images/slices/icon_collapse.png +0 -0
- data/app/assets/images/slices/icon_drag.png +0 -0
- data/app/assets/images/slices/icon_files.png +0 -0
- data/app/assets/images/slices/icon_generic_file.png +0 -0
- data/app/assets/images/slices/icon_images.png +0 -0
- data/app/assets/images/slices/icon_padlock.png +0 -0
- data/app/assets/images/slices/icon_page.png +0 -0
- data/app/assets/images/slices/icon_search.png +0 -0
- data/app/assets/images/slices/icon_set-link.png +0 -0
- data/app/assets/images/slices/icon_set.png +0 -0
- data/app/assets/images/slices/icon_sitemap.png +0 -0
- data/app/assets/images/slices/icon_snippets.png +0 -0
- data/app/assets/images/slices/icon_template.jpg +0 -0
- data/app/assets/images/slices/icon_upload_happy.png +0 -0
- data/app/assets/images/slices/icon_upload_sad.png +0 -0
- data/app/assets/images/slices/icon_upload_thinking.png +0 -0
- data/app/assets/images/slices/noise.png +0 -0
- data/app/assets/images/slices/sitemap_icon_ghost.png +0 -0
- data/app/assets/images/slices/sitemap_icon_home.png +0 -0
- data/app/assets/images/slices/sitemap_icon_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_set_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_virtual_page.png +0 -0
- data/app/assets/images/slices/sitemap_overlay.png +0 -0
- data/app/assets/images/slices/spinner.gif +0 -0
- data/app/assets/images/slices/trash.png +0 -0
- data/app/assets/javascripts/admin.js.erb +18 -0
- data/app/assets/javascripts/slices/app/backbones/admins.js +114 -0
- data/app/assets/javascripts/slices/app/backbones/entries.js +172 -0
- data/app/assets/javascripts/slices/app/backbones/generic.js +101 -0
- data/app/assets/javascripts/slices/app/backbones/snippets.js +113 -0
- data/app/assets/javascripts/slices/app/helpers/assets.js +61 -0
- data/app/assets/javascripts/slices/app/helpers/breadcrumbs.js +30 -0
- data/app/assets/javascripts/slices/app/helpers/composer.js +26 -0
- data/app/assets/javascripts/slices/app/helpers/date_field.js +16 -0
- data/app/assets/javascripts/slices/app/helpers/get_value.js +31 -0
- data/app/assets/javascripts/slices/app/helpers/icon_upload_names.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/layout.js +20 -0
- data/app/assets/javascripts/slices/app/helpers/sitemap.js +150 -0
- data/app/assets/javascripts/slices/app/helpers/slice_preview.js +48 -0
- data/app/assets/javascripts/slices/app/helpers/tagging.js +73 -0
- data/app/assets/javascripts/slices/app/helpers/token_field.js +17 -0
- data/app/assets/javascripts/slices/app/helpers/upload_icons.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/uploader.js +127 -0
- data/app/assets/javascripts/slices/app/models/asset.js +29 -0
- data/app/assets/javascripts/slices/app/models/asset_collection.js +41 -0
- data/app/assets/javascripts/slices/app/models/attachment.js +29 -0
- data/app/assets/javascripts/slices/app/models/attachment_collection.js +7 -0
- data/app/assets/javascripts/slices/app/models/composer_item.js +1 -0
- data/app/assets/javascripts/slices/app/models/composer_item_collection.js +3 -0
- data/app/assets/javascripts/slices/app/models/file.js +103 -0
- data/app/assets/javascripts/slices/app/models/page.js +186 -0
- data/app/assets/javascripts/slices/app/models/s3_file.js +64 -0
- data/app/assets/javascripts/slices/app/slices.js +661 -0
- data/app/assets/javascripts/slices/app/views/asset_editor_view.js.erb +209 -0
- data/app/assets/javascripts/slices/app/views/asset_library_view.js +720 -0
- data/app/assets/javascripts/slices/app/views/asset_thumb_view.js.erb +191 -0
- data/app/assets/javascripts/slices/app/views/attachment_composer_view.js +350 -0
- data/app/assets/javascripts/slices/app/views/attachment_view.js +101 -0
- data/app/assets/javascripts/slices/app/views/calendar_view.js +198 -0
- data/app/assets/javascripts/slices/app/views/composer_item_view.js +54 -0
- data/app/assets/javascripts/slices/app/views/composer_view.js +130 -0
- data/app/assets/javascripts/slices/app/views/date_field_view.js +177 -0
- data/app/assets/javascripts/slices/app/views/file_view.js +142 -0
- data/app/assets/javascripts/slices/app/views/token_field_view.js +253 -0
- data/app/assets/javascripts/slices/lib/freeze.js +14 -0
- data/app/assets/javascripts/slices/lib/human_file_size.js +16 -0
- data/app/assets/javascripts/slices/lib/json_patch.js +9 -0
- data/app/assets/javascripts/slices/lib/moment.js +47 -0
- data/app/assets/javascripts/slices/lib/plugins.js +101 -0
- data/app/assets/javascripts/slices/lib/sortable.js +14 -0
- data/app/assets/javascripts/slices/slices.js +27 -0
- data/app/assets/javascripts/slices/vendor/autoscroll.js +188 -0
- data/app/assets/javascripts/slices/vendor/backbone.js +38 -0
- data/app/assets/javascripts/slices/vendor/handlebars.js +1920 -0
- data/app/assets/javascripts/slices/vendor/jqmodal.js +69 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui.js +274 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui_nested-sortable.js +357 -0
- data/app/assets/javascripts/slices/vendor/jquery.ajaxprogress.js +76 -0
- data/app/assets/javascripts/slices/vendor/jquery.js +2 -0
- data/app/assets/javascripts/slices/vendor/livefield.js +459 -0
- data/app/assets/javascripts/slices/vendor/moment.js +6 -0
- data/app/assets/javascripts/slices/vendor/rails.js +315 -0
- data/app/assets/javascripts/slices/vendor/underscore-string.js +1 -0
- data/app/assets/javascripts/slices/vendor/underscore.js +5 -0
- data/app/assets/stylesheets/admin.css +1 -0
- data/app/assets/stylesheets/slices/admin.css.erb +2237 -0
- data/app/assets/stylesheets/slices/reset_html5.css +106 -0
- data/app/assets/stylesheets/slices/slices.css +7 -0
- data/app/controllers/admin/admin_controller.rb +10 -0
- data/app/controllers/admin/admins_controller.rb +76 -0
- data/app/controllers/admin/assets_controller.rb +53 -0
- data/app/controllers/admin/auth/omniauth_callbacks_controller.rb +15 -0
- data/app/controllers/admin/auth/passwords_controller.rb +4 -0
- data/app/controllers/admin/auth/sessions_controller.rb +4 -0
- data/app/controllers/admin/entries_controller.rb +88 -0
- data/app/controllers/admin/page_search_controller.rb +12 -0
- data/app/controllers/admin/pages_controller.rb +103 -0
- data/app/controllers/admin/site_maps_controller.rb +15 -0
- data/app/controllers/admin/snippets_controller.rb +33 -0
- data/app/controllers/application_controller.rb +4 -0
- data/app/controllers/pages_controller.rb +45 -0
- data/app/controllers/slices_controller.rb +63 -0
- data/app/controllers/static_assets_controller.rb +52 -0
- data/app/helpers/admin/admin_helper.rb +63 -0
- data/app/helpers/admin/assets_helper.rb +36 -0
- data/app/helpers/admin/entries_helper.rb +13 -0
- data/app/helpers/admin/site_maps_helper.rb +104 -0
- data/app/helpers/assets_helper.rb +64 -0
- data/app/helpers/navigation_helper.rb +195 -0
- data/app/helpers/pages_helper.rb +119 -0
- data/app/models/admin.rb +34 -0
- data/app/models/asset.rb +211 -0
- data/app/models/attachment.rb +11 -0
- data/app/models/layout.rb +44 -0
- data/app/models/page.rb +214 -0
- data/app/models/placeholder_slice.rb +8 -0
- data/app/models/set_page.rb +12 -0
- data/app/models/set_slice.rb +57 -0
- data/app/models/site_map.rb +24 -0
- data/app/models/slice.rb +80 -0
- data/app/models/snippet.rb +21 -0
- data/app/observers/asset_observer.rb +6 -0
- data/app/observers/page_observer.rb +37 -0
- data/app/presenters/entry_presenter.rb +17 -0
- data/app/presenters/page_presenter.rb +67 -0
- data/app/presenters/presenter.rb +9 -0
- data/app/presenters/set_page_presenter.rb +2 -0
- data/app/views/admin/admins/index.html.erb +26 -0
- data/app/views/admin/admins/show.html.erb +27 -0
- data/app/views/admin/assets/index.html.erb +1 -0
- data/app/views/admin/auth/passwords/edit.html.erb +20 -0
- data/app/views/admin/auth/passwords/new.html.erb +14 -0
- data/app/views/admin/auth/sessions/_form.html.erb +35 -0
- data/app/views/admin/auth/sessions/new.html.erb +14 -0
- data/app/views/admin/entries/index.html.erb +32 -0
- data/app/views/admin/pages/_breadcrumbs.html.erb +32 -0
- data/app/views/admin/pages/_slices.html.erb +27 -0
- data/app/views/admin/pages/new.html.erb +14 -0
- data/app/views/admin/pages/show.html.erb +50 -0
- data/app/views/admin/shared/_asset_storage.html.erb +17 -0
- data/app/views/admin/shared/_custom_links.html.erb +1 -0
- data/app/views/admin/shared/_custom_navigation.html.erb +1 -0
- data/app/views/admin/shared/_navigation.html.erb +5 -0
- data/app/views/admin/site_maps/_page_li.html.erb +20 -0
- data/app/views/admin/site_maps/_set_page_li.html.erb +23 -0
- data/app/views/admin/site_maps/index.html.erb +29 -0
- data/app/views/admin/snippets/form.html.erb +12 -0
- data/app/views/admin/snippets/index.html.erb +20 -0
- data/app/views/admin/snippets/update.html.erb +0 -0
- data/app/views/layouts/admin.html.erb +72 -0
- data/lib/ext/file_store_cache.rb +18 -0
- data/lib/generators/humans/USAGE +8 -0
- data/lib/generators/humans/humans_generator.rb +10 -0
- data/lib/generators/humans/templates/humans.txt +6 -0
- data/lib/generators/slice/USAGE +28 -0
- data/lib/generators/slice/slice_generator.rb +123 -0
- data/lib/generators/slice/templates/main_fields.hbs +11 -0
- data/lib/generators/slice/templates/meta_fields.hbs +11 -0
- data/lib/generators/slice/templates/page.rb +19 -0
- data/lib/generators/slice/templates/presenter.rb +53 -0
- data/lib/generators/slice/templates/set.html.erb +8 -0
- data/lib/generators/slice/templates/set_slice.rb +14 -0
- data/lib/generators/slice/templates/set_slice_fields.hbs +5 -0
- data/lib/generators/slice/templates/show.html.erb +48 -0
- data/lib/generators/slice/templates/show_slice.rb +20 -0
- data/lib/generators/slice/templates/slice.rb +58 -0
- data/lib/generators/slice/templates/slice_fields.hbs +74 -0
- data/lib/generators/templates/slices.rb +211 -0
- data/lib/mongo_search.rb +84 -0
- data/lib/paperclip_validator.rb +5 -0
- data/lib/rack_utf8_fix.rb +10 -0
- data/lib/sRGB.icc +0 -0
- data/lib/set_link_renderer.rb +31 -0
- data/lib/slices.rb +68 -0
- data/lib/slices/asset/maker.rb +55 -0
- data/lib/slices/asset/rename.rb +67 -0
- data/lib/slices/available_slices.rb +43 -0
- data/lib/slices/cms_form_builder.rb +42 -0
- data/lib/slices/config.rb +93 -0
- data/lib/slices/container_parser.rb +70 -0
- data/lib/slices/generator_macros.rb +36 -0
- data/lib/slices/has_attachments.rb +111 -0
- data/lib/slices/has_slices.rb +88 -0
- data/lib/slices/i18n.rb +6 -0
- data/lib/slices/i18n/backend.rb +32 -0
- data/lib/slices/i18n_backend.rb +24 -0
- data/lib/slices/paperclip.rb +13 -0
- data/lib/slices/position_helper.rb +98 -0
- data/lib/slices/renderer.rb +52 -0
- data/lib/slices/slices_engine.rb +51 -0
- data/lib/slices/split_date_time_field.rb +14 -0
- data/lib/slices/tasks/assets.rake +35 -0
- data/lib/slices/tasks/db.rake +50 -0
- data/lib/slices/tasks/seeds.rake +93 -0
- data/lib/slices/tasks/validate.rake +62 -0
- data/lib/slices/tree.rb +306 -0
- data/lib/slices/version.rb +4 -0
- data/lib/slices/will_paginate.rb +12 -0
- data/lib/slices/will_paginate_mongoid.rb +45 -0
- data/lib/standard_tree.rb +193 -0
- metadata +483 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
window.humanFileSize = function(bytes) {
|
2
|
+
bytes = parseInt(bytes, 10);
|
3
|
+
|
4
|
+
if (isNaN(bytes)) return 'N/A';
|
5
|
+
|
6
|
+
var ONE_KB = 1024,
|
7
|
+
ONE_MB = ONE_KB * 1024,
|
8
|
+
ONE_GB = ONE_MB * 1024;
|
9
|
+
|
10
|
+
if (bytes >= ONE_GB) return (bytes / ONE_GB).toFixed(2) + ' GB';
|
11
|
+
if (bytes >= ONE_MB) return (bytes / ONE_MB).toFixed(2) + ' MB';
|
12
|
+
if (bytes >= ONE_KB) return Math.floor(bytes / ONE_KB) + ' KB';
|
13
|
+
|
14
|
+
return bytes + 'b';
|
15
|
+
}
|
16
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
moment.lang('en-gb', {
|
2
|
+
months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
3
|
+
monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
|
4
|
+
weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
5
|
+
weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
|
6
|
+
longDateFormat : {
|
7
|
+
LT : "h:mma",
|
8
|
+
L : "D/M/YYYY",
|
9
|
+
LL : "Do MMMM YYYY",
|
10
|
+
LLL : "D MMMM YYYY LT",
|
11
|
+
LLLL : "dddd, D MMMM YYYY LT"
|
12
|
+
},
|
13
|
+
calendar : {
|
14
|
+
sameDay : '[today at] LT',
|
15
|
+
nextDay : '[tomorrow at] LT',
|
16
|
+
nextWeek : 'dddd [at] LT',
|
17
|
+
lastDay : '[yesterday at] LT',
|
18
|
+
lastWeek : '[last] dddd [at] LT',
|
19
|
+
sameElse : 'LL'
|
20
|
+
},
|
21
|
+
relativeTime : {
|
22
|
+
future : "in %s",
|
23
|
+
past : "%s ago",
|
24
|
+
s : "a few seconds",
|
25
|
+
m : "a minute",
|
26
|
+
mm : "%d minutes",
|
27
|
+
h : "an hour",
|
28
|
+
hh : "%d hours",
|
29
|
+
d : "a day",
|
30
|
+
dd : "%d days",
|
31
|
+
M : "a month",
|
32
|
+
MM : "%d months",
|
33
|
+
y : "a year",
|
34
|
+
yy : "%d years"
|
35
|
+
},
|
36
|
+
ordinal : function (number) {
|
37
|
+
var b = number % 10;
|
38
|
+
return (~~ (number % 100 / 10) === 1) ? 'th' :
|
39
|
+
(b === 1) ? 'st' :
|
40
|
+
(b === 2) ? 'nd' :
|
41
|
+
(b === 3) ? 'rd' : 'th';
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
moment.fn.is = function(other) {
|
46
|
+
return other && this.valueOf() === other.valueOf();
|
47
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
// File to keep the simpler abstracted visual plugins seperate from the rest of the code...
|
2
|
+
window.log = function(){
|
3
|
+
log.history = log.history || []; // store logs to an array for reference
|
4
|
+
log.history.push(arguments);
|
5
|
+
if(this.console) {
|
6
|
+
console.log( Array.prototype.slice.call(arguments) );
|
7
|
+
}
|
8
|
+
};
|
9
|
+
|
10
|
+
// simple editinplace functionality
|
11
|
+
(function ($, window, undefined) {
|
12
|
+
|
13
|
+
// Shows a message whenever an ajax communication to the server is occuring...
|
14
|
+
$(function () {
|
15
|
+
var sc = $('#server-communication').ajaxStart(
|
16
|
+
|
17
|
+
function () {
|
18
|
+
sc.show();
|
19
|
+
}).ajaxStop(
|
20
|
+
|
21
|
+
function () {
|
22
|
+
sc.hide();
|
23
|
+
});
|
24
|
+
});
|
25
|
+
// Loops over all eligible items [selects, checkboxes and radio buttons] within the called on element and sets their
|
26
|
+
// state to represent the contents of their data-value attribute
|
27
|
+
$.fn.applyDataValues = function () {
|
28
|
+
this.find('select').each(function () {
|
29
|
+
var select = $(this);
|
30
|
+
var selectedValue = select.data('value');
|
31
|
+
select.find('option[value="' + selectedValue + '"]').attr('selected', 'selected');
|
32
|
+
select.val(selectedValue);
|
33
|
+
});
|
34
|
+
|
35
|
+
this.find(':checkbox').each(function () {
|
36
|
+
var cb = $(this);
|
37
|
+
if (cb.data('value') == 'true' || cb.data('value') == '1') {
|
38
|
+
cb.attr('checked', 'checked');
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
this.find(':radio').each(function () {
|
43
|
+
var rad = $(this),
|
44
|
+
parent = rad.closest('[data-value]'),
|
45
|
+
selectedValue = parent.data('value');
|
46
|
+
|
47
|
+
if (rad.val() == selectedValue) rad.attr('checked', 'checked');
|
48
|
+
});
|
49
|
+
|
50
|
+
return this;
|
51
|
+
}
|
52
|
+
|
53
|
+
// Implements edit in place functionality...
|
54
|
+
$.fn.editinplace = function (settings) {
|
55
|
+
this.find('textarea,input[type=text]').each(
|
56
|
+
function () {
|
57
|
+
var ta = $(this);
|
58
|
+
var val = ta.val();
|
59
|
+
ta.after(
|
60
|
+
$('<span />').attr({
|
61
|
+
'class': ta.attr('class')
|
62
|
+
}).text(val)).remove();
|
63
|
+
});
|
64
|
+
this.find('.editinplace').bind('click', function () {
|
65
|
+
var span = $(this),
|
66
|
+
val = span.text()
|
67
|
+
inp = $(span.is('.long') ? '<textarea id="editing-in-place" />' : '<input id="editing-in-place" type="text" />')
|
68
|
+
.val(val).
|
69
|
+
focus()
|
70
|
+
.bind('keydown', function (e) {
|
71
|
+
// Need to capture enter so that if somebody presses return and submits the
|
72
|
+
// form then we blur first and the updated value is submitted...
|
73
|
+
var keyCode = (window.event) ? e.which : e.keyCode;
|
74
|
+
if (keyCode === 13) {
|
75
|
+
var f = this.form;
|
76
|
+
$(this).blur();
|
77
|
+
$(f).trigger('submit');
|
78
|
+
}
|
79
|
+
})
|
80
|
+
.bind('blur', function () {
|
81
|
+
var inp = $(this);
|
82
|
+
span.text(inp.val()).show();
|
83
|
+
inp.remove();
|
84
|
+
});
|
85
|
+
if (span.siblings('label').length == 1) {
|
86
|
+
inp.attr('name', span.siblings('label').attr('for'))
|
87
|
+
}
|
88
|
+
span.after(inp).hide();
|
89
|
+
inp.focus();
|
90
|
+
});
|
91
|
+
}
|
92
|
+
|
93
|
+
$.fn.initDataPlugins = function() {
|
94
|
+
this.find('[data-plugin]').each(function() {
|
95
|
+
var e = $(this), plugin = e.attr('data-plugin');
|
96
|
+
if (_.isFunction(e[plugin])) e[plugin]();
|
97
|
+
});
|
98
|
+
return this;
|
99
|
+
}
|
100
|
+
|
101
|
+
})(jQuery, this);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
* Patch for sortable and nestedSortable scroll jump issue
|
3
|
+
*/
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
var superMouseStart = $.ui.sortable.prototype._mouseStart;
|
8
|
+
$.ui.sortable.prototype._superMouseStart = superMouseStart;
|
9
|
+
$.ui.sortable.prototype._mouseStart = function(event, overrideHandle, noActivation) {
|
10
|
+
this._trigger("beforeStart", event, this._uiHash());
|
11
|
+
this._superMouseStart(event, overrideHandle, noActivation);
|
12
|
+
}
|
13
|
+
|
14
|
+
})(jQuery);
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/*
|
2
|
+
*= require_self
|
3
|
+
*= require slices/vendor/rails
|
4
|
+
*= require slices/vendor/handlebars
|
5
|
+
*= require slices/vendor/underscore
|
6
|
+
*= require slices/vendor/underscore-string
|
7
|
+
*= require slices/vendor/backbone
|
8
|
+
*= require slices/vendor/autoscroll
|
9
|
+
*= require slices/vendor/jqmodal
|
10
|
+
*= require slices/vendor/jquery-ui
|
11
|
+
*= require slices/vendor/livefield
|
12
|
+
*= require slices/vendor/moment
|
13
|
+
|
14
|
+
*= require_tree ./lib
|
15
|
+
*= require slices/vendor/jquery-ui_nested-sortable
|
16
|
+
*= require slices/vendor/jquery.ajaxprogress.js
|
17
|
+
|
18
|
+
*= require slices/app/slices
|
19
|
+
*= require_tree ./app/models
|
20
|
+
*= require slices/app/backbones/generic
|
21
|
+
*= require_tree ./app/backbones
|
22
|
+
*= require_tree ./app/helpers
|
23
|
+
*= require_tree ./app/views
|
24
|
+
|
25
|
+
*= require admin
|
26
|
+
*/
|
27
|
+
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/*
|
2
|
+
* # AutoScroll 1.1.1
|
3
|
+
*
|
4
|
+
* http://github.com/withassociates/autoscroll.js
|
5
|
+
*
|
6
|
+
* Simplest possible autoscrolling library.
|
7
|
+
* Creates a top-level instance to start/stop the behaviour.
|
8
|
+
*
|
9
|
+
* ## Usage
|
10
|
+
*
|
11
|
+
* window.autoscroll.start();
|
12
|
+
* window.autoscroll.stop();
|
13
|
+
*
|
14
|
+
* ## Settings & Defaults
|
15
|
+
*
|
16
|
+
* window.autoscroll.interval = 1000 / 60
|
17
|
+
* window.autoscroll.threshold = 50
|
18
|
+
* window.autoscroll.velocity = 2
|
19
|
+
* window.autoscroll.acceleration = 0.01
|
20
|
+
*
|
21
|
+
* ## Dependencies
|
22
|
+
*
|
23
|
+
* * jQuery ~> 1.5.2
|
24
|
+
*
|
25
|
+
* ## Contributors
|
26
|
+
*
|
27
|
+
* * jamie@withassociates.com
|
28
|
+
*
|
29
|
+
* Licensed under the terms of the MIT license.
|
30
|
+
*/
|
31
|
+
|
32
|
+
(function($) {
|
33
|
+
|
34
|
+
// class AutoScroll
|
35
|
+
var AutoScroll = function() {
|
36
|
+
var self = this;
|
37
|
+
self.version = '1.1.1';
|
38
|
+
|
39
|
+
// starts autoscroll listening for events and performing scrolling
|
40
|
+
self.start = function() {
|
41
|
+
if (self.running) return;
|
42
|
+
reset();
|
43
|
+
listen();
|
44
|
+
update();
|
45
|
+
self.running = true;
|
46
|
+
}
|
47
|
+
|
48
|
+
// shuts down autoscroll
|
49
|
+
self.stop = function() {
|
50
|
+
if (!self.running) return;
|
51
|
+
clearTimeout(timeout);
|
52
|
+
stopListening();
|
53
|
+
self.running = false;
|
54
|
+
}
|
55
|
+
|
56
|
+
// defaults
|
57
|
+
self.interval = 1000 / 60;
|
58
|
+
self.threshold = 50;
|
59
|
+
self.velocity = 2;
|
60
|
+
self.acceleration = 0.01;
|
61
|
+
|
62
|
+
// private properties
|
63
|
+
var mouseNow,
|
64
|
+
reset,
|
65
|
+
scrollingUp,
|
66
|
+
scrollingDown,
|
67
|
+
timeout,
|
68
|
+
viewportNow,
|
69
|
+
pageNow,
|
70
|
+
whenScrollingStarted,
|
71
|
+
$window = $(window),
|
72
|
+
$document = $(document);
|
73
|
+
|
74
|
+
// private methods
|
75
|
+
var checkTop,
|
76
|
+
checkBottom,
|
77
|
+
listen,
|
78
|
+
stopListening,
|
79
|
+
onMouseMove,
|
80
|
+
onResize,
|
81
|
+
update,
|
82
|
+
velocity,
|
83
|
+
triggerMouseMove;
|
84
|
+
|
85
|
+
onMouseMove = function(event) {
|
86
|
+
mouseNow = {
|
87
|
+
pageX: event.pageX,
|
88
|
+
pageY: event.pageY,
|
89
|
+
x: event.pageX - $window.scrollLeft(),
|
90
|
+
y: event.pageY - $window.scrollTop()
|
91
|
+
};
|
92
|
+
}
|
93
|
+
|
94
|
+
onResize = function() {
|
95
|
+
viewportNow = {
|
96
|
+
width: $window.width(),
|
97
|
+
height: $window.height()
|
98
|
+
};
|
99
|
+
pageNow = {
|
100
|
+
width: $('body').outerWidth(),
|
101
|
+
height: $('body').outerHeight()
|
102
|
+
}
|
103
|
+
$('body > *').each(function() {
|
104
|
+
pageNow.height = Math.max(pageNow.height, $(this).outerHeight());
|
105
|
+
});
|
106
|
+
}
|
107
|
+
|
108
|
+
checkTop = function() {
|
109
|
+
var isPastThreshold = mouseNow.y < self.threshold,
|
110
|
+
isAtMin = $window.scrollTop() <= 0;
|
111
|
+
|
112
|
+
if (isPastThreshold && !isAtMin) {
|
113
|
+
if (!scrollingUp) {
|
114
|
+
scrollingUp = true;
|
115
|
+
whenScrollingStarted = new Date();
|
116
|
+
}
|
117
|
+
var v = velocity();
|
118
|
+
$window.scrollTop($window.scrollTop() - v);
|
119
|
+
triggerMouseMove(0, -v);
|
120
|
+
} else {
|
121
|
+
scrollingUp = false;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
checkBottom = function() {
|
126
|
+
var isPastThreshold = mouseNow.y > viewportNow.height - self.threshold,
|
127
|
+
isAtMax = $window.scrollTop() >= pageNow.height - $window.height();
|
128
|
+
|
129
|
+
if (isPastThreshold && !isAtMax) {
|
130
|
+
if (!scrollingDown) {
|
131
|
+
scrollingDown = true;
|
132
|
+
whenScrollingStarted = new Date();
|
133
|
+
}
|
134
|
+
var v = velocity();
|
135
|
+
$window.scrollTop($window.scrollTop() + v);
|
136
|
+
triggerMouseMove(0, v);
|
137
|
+
} else {
|
138
|
+
scrollingDown = false;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
velocity = function() {
|
143
|
+
var now = new Date(),
|
144
|
+
time = now - whenScrollingStarted;
|
145
|
+
|
146
|
+
return Math.round(self.velocity + (self.acceleration * time));
|
147
|
+
}
|
148
|
+
|
149
|
+
triggerMouseMove = function(dx, dy) {
|
150
|
+
$document.trigger($.Event('mousemove', {
|
151
|
+
pageX: mouseNow.pageX + dx,
|
152
|
+
pageY: mouseNow.pageY + dy
|
153
|
+
}));
|
154
|
+
}
|
155
|
+
|
156
|
+
update = function() {
|
157
|
+
if (mouseNow) {
|
158
|
+
checkTop();
|
159
|
+
checkBottom();
|
160
|
+
}
|
161
|
+
timeout = setTimeout(update, self.interval);
|
162
|
+
}
|
163
|
+
|
164
|
+
reset = function() {
|
165
|
+
delete mouseNow;
|
166
|
+
delete scrollingUp;
|
167
|
+
delete scrollingDown;
|
168
|
+
delete whenScrollingStarted;
|
169
|
+
}
|
170
|
+
|
171
|
+
listen = function() {
|
172
|
+
$document.bind('mousemove', onMouseMove);
|
173
|
+
$document.bind('resize', onResize);
|
174
|
+
onResize();
|
175
|
+
}
|
176
|
+
|
177
|
+
stopListening = function() {
|
178
|
+
$document.unbind('mousemove', onMouseMove);
|
179
|
+
$document.unbind('resize', onResize);
|
180
|
+
}
|
181
|
+
|
182
|
+
}
|
183
|
+
|
184
|
+
// Create top-level instance
|
185
|
+
// We don't want more than one, so we can lose the constructor after this.
|
186
|
+
window.autoscroll = new AutoScroll();
|
187
|
+
|
188
|
+
})(jQuery);
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// Backbone.js 0.9.2
|
2
|
+
|
3
|
+
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
4
|
+
// Backbone may be freely distributed under the MIT license.
|
5
|
+
// For all details and documentation:
|
6
|
+
// http://backbonejs.org
|
7
|
+
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
|
8
|
+
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
|
9
|
+
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
|
10
|
+
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
|
11
|
+
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
|
12
|
+
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
|
13
|
+
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
|
14
|
+
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
|
15
|
+
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
16
|
+
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
|
17
|
+
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
|
18
|
+
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
|
19
|
+
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
|
20
|
+
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
|
21
|
+
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
|
22
|
+
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
|
23
|
+
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
|
24
|
+
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
|
25
|
+
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
|
26
|
+
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
|
27
|
+
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
|
28
|
+
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
|
29
|
+
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
|
30
|
+
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
|
31
|
+
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
|
32
|
+
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
|
33
|
+
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
|
34
|
+
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
|
35
|
+
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
|
36
|
+
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
|
37
|
+
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
|
38
|
+
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
|