├── .gitignore
├── README.md
├── css
└── backbone.upload-manager.css
├── docs
└── options.md
├── images
└── sprite.png
├── js
└── backbone.upload-manager.js
├── psd
└── sprite.psd
├── sample
├── index.html
└── vendor
│ ├── css
│ ├── bootstrap-2.3.1.css
│ └── bootstrap-responsive-2.3.1.css
│ └── js
│ ├── backbone-1.0.0.js
│ ├── backbone.defered-view-loader.js
│ ├── jquery-1.9.1.js
│ ├── jquery.fileupload.js
│ ├── jquery.iframe-transport.js
│ ├── jquery.ui.widget.js
│ └── underscore-1.4.4.js
└── templates
├── upload-manager.file
└── upload-manager.main
/.gitignore:
--------------------------------------------------------------------------------
1 | /.settings
2 | /.project
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Backbone Upload Manager
2 |
3 | A simple upload manager written with Backbone.js.
4 |
5 | * [Demonstration and usage](http://sroze.github.io/backbone-upload-manager)
6 |
7 |
8 |
9 | [](https://bitdeli.com/free "Bitdeli Badge")
10 |
11 |
--------------------------------------------------------------------------------
/css/backbone.upload-manager.css:
--------------------------------------------------------------------------------
1 | .upload-manager {
2 | border: 1px solid #CCCCCC;
3 | border-radius: 4px 4px 4px 4px;
4 | -webkit-border-radius: 4px 4px 4px 4px;
5 | -moz-border-radius: 4px 4px 4px 4px;
6 | box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
7 | -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
8 | -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
9 | text-align: left;
10 | }
11 | .upload-manager footer {
12 | background: #F4F4F4;
13 | border-top: 1px solid #DDDDDD;
14 | padding: 10px;
15 | }
16 | .upload-manager .fileinput-button input {
17 | cursor: pointer;
18 | direction: ltr;
19 | font-size: 23px;
20 | margin: 0;
21 | opacity: 0;
22 | -webkit-opacity: 0;
23 | -moz-opacity: 0;
24 | position: absolute;
25 | right: 0;
26 | top: 0;
27 | transform: translate(-300px, 0px) scale(4);
28 | -webkit-transform: translate(-300px, 0px) scale(4);
29 | -moz-transform: translate(-300px, 0px) scale(4);
30 | -ms-transform: translate(-300px, 0px) scale(4);
31 | -o-transform: translate(-300px, 0px) scale(4);
32 | }
33 | .upload-manager .fileinput-button {
34 | overflow: hidden;
35 | position: relative;
36 | }
37 | .upload-manager .message.error {
38 | color: #BD362F;
39 | }
40 | .upload-manager .message.done {
41 | color: #57ba48;
42 | }
43 | .upload-manager .progress {
44 | position: relative;
45 | }
46 | .upload-manager .progress .progress-label {
47 | position: absolute;
48 | width: 100%;
49 | text-align: center;
50 | text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
51 | color: #fff;
52 | }
53 | .upload-manager i {
54 | background: url("../images/sprite.png");
55 | display: inline-block;
56 | vertical-align: middle;
57 | margin: 4px;
58 | height: 16px;
59 | width: 16px;
60 | }
61 | .upload-manager .icon-cancel {
62 | background-position: 0 0;
63 | }
64 | .upload-manager .icon-start {
65 | background-position: -32px 0;
66 | }
67 | .upload-manager .icon-plus {
68 | background-position: -80px 0;
69 | }
70 | .upload-manager .icon-error {
71 | background-position: -96px 0;
72 | }
73 | .upload-manager .icon-success {
74 | background-position: -112px 0;
75 | }
76 | .upload-manager .icon-remove {
77 | background-position: -144px 0;
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/docs/options.md:
--------------------------------------------------------------------------------
1 | # Options
2 |
3 | There is the list of available options.
4 |
5 | ##
--------------------------------------------------------------------------------
/images/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sroze/backbone-upload-manager/abcca1d0b253ab87a10867637c9e0d3aa3577353/images/sprite.png
--------------------------------------------------------------------------------
/js/backbone.upload-manager.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Backbone Upload Manager v1.0.0
4 | *
5 | * Copyright (c) 2013 Samuel ROZE
6 | *
7 | * License and more information at:
8 | * http://github.com/sroze/backbone-upload-manager
9 | */
10 | (function(Backbone){
11 | Backbone.UploadManager = Backbone.DeferedView.extend({
12 | /**
13 | * Default options, that will be merged with the passed.
14 | *
15 | */
16 | defaults: {
17 | templates: {
18 | main: '/templates/upload-manager.main.default',
19 | file: '/templates/upload-manager.file.default'
20 | },
21 | uploadUrl: '/upload',
22 | autoUpload: false,
23 | fileUploadId: 'fileupload',
24 | startUploadsId: 'start-uploads-button',
25 | cancelUploadsId: 'cancel-uploads-button',
26 | dataType: 'json'
27 | },
28 |
29 | /**
30 | * An integer used to track the files by a unique
31 | * identifier.
32 | *
33 | */
34 | file_id: 0,
35 |
36 | /**
37 | * View container class.
38 | *
39 | */
40 | className: 'upload-manager',
41 |
42 | /**
43 | * Initialize upload manager options
44 | *
45 | */
46 | initialize: function (options)
47 | {
48 | // Merge options
49 | this.options = $.extend(this.defaults, options);
50 |
51 | // Update template name
52 | this.templateName = this.options.templates.main;
53 |
54 | // Create the file list
55 | this.files = new Backbone.UploadManager.FileCollection();
56 |
57 | // Create the file-upload wrapper
58 | this.uploadProcess = $('').fileupload({
59 | dataType: this.options.dataType,
60 | url: this.options.uploadUrl,
61 | formData: this.options.formData,
62 | autoUpload: this.options.autoUpload,
63 | singleFileUploads: true
64 | });
65 |
66 | // Add upload process events handlers
67 | this.bindProcessEvents();
68 |
69 | // Add local events handlers
70 | this.bindLocal();
71 | },
72 |
73 | /**
74 | * Bind local events.
75 | *
76 | */
77 | bindLocal: function ()
78 | {
79 | var self = this;
80 | this.on('fileadd', function (file) {
81 | // Add it to current list
82 | self.files.add(file);
83 |
84 | // Create the view
85 | self.renderFile(file);
86 | }).on('fileprogress', function (file, progress) {
87 | file.progress(progress);
88 | }).on('filefail', function (file, error) {
89 | file.fail(error);
90 | }).on('filedone', function (file, data) {
91 | file.done(data.result);
92 | });
93 |
94 | // When collection changes
95 | this.files.on('all', this.update, this);
96 | },
97 |
98 | /**
99 | * Render a file.
100 | *
101 | */
102 | renderFile: function (file)
103 | {
104 | var file_view = new Backbone.UploadManager.FileView($.extend(this.options, {model: file}));
105 | $('#file-list', self.el).append(file_view.deferedRender().el);
106 | },
107 |
108 | /**
109 | * Update the view without full rendering.
110 | *
111 | */
112 | update: function ()
113 | {
114 | var with_files_elements = $('#' + this.options.cancelUploadsId + ', #' + this.options.startUploadsId, this.el);
115 | var without_files_elements = $('#file-list .no-data', this.el);
116 | if (this.files.length > 0) {
117 | with_files_elements.removeClass('hidden');
118 | without_files_elements.addClass('hidden');
119 | } else {
120 | with_files_elements.addClass('hidden');
121 | without_files_elements.removeClass('hidden');
122 | }
123 | },
124 |
125 | /**
126 | * Bind events on the upload processor.
127 | *
128 | */
129 | bindProcessEvents: function ()
130 | {
131 | var self = this;
132 | this.uploadProcess.on('fileuploadadd', function (e, data) {
133 | // Create an array in which the file objects
134 | // will be stored.
135 | data.uploadManagerFiles = [];
136 |
137 | // A file is added, process for each file.
138 | // Note: every times, the data.files array length is 1 because
139 | // of "singleFileUploads" option.
140 | $.each(data.files, function (index, file_data) {
141 | // Create the file object
142 | file_data.id = self.file_id++;
143 | var file = new Backbone.UploadManager.File({
144 | data: file_data,
145 | processor: data
146 | });
147 |
148 | // Add file in data
149 | data.uploadManagerFiles.push(file);
150 |
151 | // Trigger event
152 | self.trigger('fileadd', file);
153 | });
154 | }).on('fileuploadprogress', function (e, data) {
155 | $.each(data.uploadManagerFiles, function (index, file) {
156 | self.trigger('fileprogress', file, data);
157 | });
158 | }).on('fileuploadfail', function (e, data) {
159 | $.each(data.uploadManagerFiles, function (index, file) {
160 | var error = "Unknown error";
161 | if (typeof data.errorThrown == "string") {
162 | error = data.errorThrown;
163 | } else if (typeof data.errorThrown == "object") {
164 | error = data.errorThrown.message;
165 | } else if (data.result) {
166 | if (data.result.error) {
167 | error = data.result.error;
168 | } else if (data.result.files && data.result.files[index] && data.result.files[index].error) {
169 | error = data.result.files[index].error;
170 | } else {
171 | error = "Unknown remote error";
172 | }
173 | }
174 |
175 | self.trigger('filefail', file, error);
176 | });
177 | }).on('fileuploaddone', function (e, data) {
178 | $.each(data.uploadManagerFiles, function (index, file) {
179 | self.trigger('filedone', file, data);
180 | });
181 | });
182 | },
183 |
184 | /**
185 | * Render the main part of upload manager.
186 | *
187 | */
188 | render: function ()
189 | {
190 | $(this.el).html(this.template());
191 |
192 | // Update view
193 | this.update();
194 |
195 | // Add add files handler
196 | var input = $('#' + this.options.fileUploadId, this.el), self = this;
197 | input.on('change', function (){
198 | self.uploadProcess.fileupload('add', {
199 | fileInput: $(this)
200 | });
201 | });
202 |
203 | // Add cancel all handler
204 | $('#' + this.options.cancelUploadsId, this.el).click(function(){
205 | while (self.files.length) {
206 | self.files.at(0).cancel();
207 | }
208 | });
209 |
210 | // Add start uploads handler
211 | $('#' + this.options.startUploadsId, this.el).click(function(){
212 | self.files.each(function(file){
213 | file.start();
214 | });
215 | });
216 |
217 | // Render current files
218 | $.each(this.files, function (i, file) {
219 | self.renderFile(file);
220 | });
221 | }
222 | }, {
223 | /**
224 | * This model represents a file.
225 | *
226 | */
227 | File: Backbone.Model.extend({
228 | state: "pending",
229 |
230 | /**
231 | * Start upload.
232 | *
233 | */
234 | start: function ()
235 | {
236 | if (this.isPending()) {
237 | this.get('processor').submit();
238 | this.state = "running";
239 |
240 | // Dispatch event
241 | this.trigger('filestarted', this);
242 | }
243 | },
244 |
245 | /**
246 | * Cancel a file upload.
247 | *
248 | */
249 | cancel: function ()
250 | {
251 | this.get('processor').abort();
252 | this.destroy();
253 |
254 | // Dispatch event
255 | this.state = "canceled";
256 | this.trigger('filecanceled', this);
257 | },
258 |
259 | /**
260 | * Notify file that progress updated.
261 | *
262 | */
263 | progress: function (data)
264 | {
265 | // Dispatch event
266 | this.trigger('fileprogress', this.get('processor').progress());
267 | },
268 |
269 | /**
270 | * Notify file that upload failed.
271 | *
272 | */
273 | fail: function (error)
274 | {
275 | // Dispatch event
276 | this.state = "error";
277 | this.trigger('filefailed', error);
278 | },
279 |
280 | /**
281 | * Notify file that upload is done.
282 | *
283 | */
284 | done: function (result)
285 | {
286 | // Dispatch event
287 | this.state = "error";
288 | this.trigger('filedone', result);
289 | },
290 |
291 | /**
292 | * Is this file pending to be uploaded ?
293 | *
294 | */
295 | isPending: function ()
296 | {
297 | return this.getState() == "pending";
298 | },
299 |
300 | /**
301 | * Is this file currently uploading ?
302 | *
303 | */
304 | isRunning: function ()
305 | {
306 | return this.getState() == "running";
307 | },
308 |
309 | /**
310 | * Is this file uploaded ?
311 | *
312 | */
313 | isDone: function ()
314 | {
315 | return this.getState() == "done";
316 | },
317 |
318 | /**
319 | * Is this upload in error ?
320 | *
321 | */
322 | isError: function ()
323 | {
324 | return this.getState() == "error" || this.getState == "canceled";
325 | },
326 |
327 | /**
328 | * Get the file state.
329 | *
330 | */
331 | getState: function ()
332 | {
333 | return this.state;
334 | }
335 | }),
336 |
337 | /**
338 | * This is a file collection, used to manage the selected
339 | * and processing files.
340 | *
341 | */
342 | FileCollection: Backbone.Collection.extend({
343 | model: this.File
344 | }),
345 |
346 | /**
347 | * A file view, which is the view that manage a single file
348 | * process in the upload manager.
349 | *
350 | */
351 | FileView: Backbone.DeferedView.extend({
352 | className: 'upload-manager-file row-fluid',
353 |
354 | initialize: function (options) {
355 | this.templateName = options.templates.file;
356 | this.processUploadMsg = options.processUploadMsg;
357 | this.doneMsg = options.doneMsg;
358 |
359 | // Bind model events
360 | this.model.on('destroy', this.close, this);
361 | this.model.on('fileprogress', this.updateProgress, this);
362 | this.model.on('filefailed', this.hasFailed, this);
363 | this.model.on('filedone', this.hasDone, this);
364 |
365 | // In each case, update view
366 | this.model.on('all', this.update, this);
367 | },
368 |
369 | /**
370 | * Render the file item view.
371 | *
372 | */
373 | render: function ()
374 | {
375 | $(this.el).html(this.template(this.computeData()));
376 |
377 | // Bind events
378 | this.bindEvents();
379 |
380 | // Update elements
381 | this.update();
382 | },
383 |
384 | /**
385 | * Update upload progress.
386 | *
387 | */
388 | updateProgress: function (progress)
389 | {
390 | var percent = parseInt(progress.loaded / progress.total * 100, 10);
391 | var progressHTML = this.getHelpers().displaySize(progress.loaded)+' of '+this.getHelpers().displaySize(progress.total);
392 | if (percent >= 100 && this.processUploadMsg) { progressHTML = this.processUploadMsg; }
393 |
394 | $('.progress', this.el)
395 | .find('.bar')
396 | .css('width', percent+'%')
397 | .parent()
398 | .find('.progress-label')
399 | .html(progressHTML);
400 | },
401 |
402 | /**
403 | * File upload has failed.
404 | *
405 | */
406 | hasFailed: function (error)
407 | {
408 | $('.message', this.el).html(' '+error);
409 | },
410 |
411 | /**
412 | * File upload is done.
413 | *
414 | */
415 | hasDone: function (result)
416 | {
417 | $('.message', this.el).html(' ' + (this.doneMsg || 'Uploaded'));
418 | },
419 |
420 | /**
421 | * Update view without complete rendering.
422 | *
423 | */
424 | update: function ()
425 | {
426 | var when_pending = $('.size, #btn-cancel', this.el),
427 | when_running = $('.progress, #btn-cancel', this.el),
428 | when_done = $('.message, #btn-clear', this.el);
429 |
430 | if (this.model.isPending()) {
431 | when_running.add(when_done).addClass('hidden');
432 | when_pending.removeClass('hidden');
433 | } else if (this.model.isRunning()) {
434 | when_pending.add(when_done).addClass('hidden');
435 | when_running.removeClass('hidden');
436 | } else if (this.model.isDone() || this.model.isError()) {
437 | when_pending.add(when_running).addClass('hidden');
438 | when_done.removeClass('hidden');
439 | }
440 | },
441 |
442 | /**
443 | * Bind local elements events.
444 | *
445 | */
446 | bindEvents: function ()
447 | {
448 | var self = this;
449 |
450 | // DOM events
451 | $('#btn-cancel', this.el).click(function(){
452 | self.model.cancel();
453 | self.collection.remove(self.model);
454 | });
455 | $('#btn-clear', this.el).click(function(){
456 | self.model.destroy();
457 | self.collection.remove(self.model);
458 | });
459 | },
460 |
461 | /**
462 | * Compute data to be passed to the view.
463 | *
464 | */
465 | computeData: function ()
466 | {
467 | return $.extend(this.getHelpers(), this.model.get('data'));
468 | }
469 | })
470 | });
471 | })(Backbone);
472 |
--------------------------------------------------------------------------------
/psd/sprite.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sroze/backbone-upload-manager/abcca1d0b253ab87a10867637c9e0d3aa3577353/psd/sprite.psd
--------------------------------------------------------------------------------
/sample/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ",
227 | options: {
228 | disabled: false,
229 |
230 | // callbacks
231 | create: null
232 | },
233 | _createWidget: function( options, element ) {
234 | element = $( element || this.defaultElement || this )[ 0 ];
235 | this.element = $( element );
236 | this.uuid = uuid++;
237 | this.eventNamespace = "." + this.widgetName + this.uuid;
238 | this.options = $.widget.extend( {},
239 | this.options,
240 | this._getCreateOptions(),
241 | options );
242 |
243 | this.bindings = $();
244 | this.hoverable = $();
245 | this.focusable = $();
246 |
247 | if ( element !== this ) {
248 | $.data( element, this.widgetFullName, this );
249 | this._on( true, this.element, {
250 | remove: function( event ) {
251 | if ( event.target === element ) {
252 | this.destroy();
253 | }
254 | }
255 | });
256 | this.document = $( element.style ?
257 | // element within the document
258 | element.ownerDocument :
259 | // element is window or document
260 | element.document || element );
261 | this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
262 | }
263 |
264 | this._create();
265 | this._trigger( "create", null, this._getCreateEventData() );
266 | this._init();
267 | },
268 | _getCreateOptions: $.noop,
269 | _getCreateEventData: $.noop,
270 | _create: $.noop,
271 | _init: $.noop,
272 |
273 | destroy: function() {
274 | this._destroy();
275 | // we can probably remove the unbind calls in 2.0
276 | // all event bindings should go through this._on()
277 | this.element
278 | .unbind( this.eventNamespace )
279 | // 1.9 BC for #7810
280 | // TODO remove dual storage
281 | .removeData( this.widgetName )
282 | .removeData( this.widgetFullName )
283 | // support: jquery <1.6.3
284 | // http://bugs.jquery.com/ticket/9413
285 | .removeData( $.camelCase( this.widgetFullName ) );
286 | this.widget()
287 | .unbind( this.eventNamespace )
288 | .removeAttr( "aria-disabled" )
289 | .removeClass(
290 | this.widgetFullName + "-disabled " +
291 | "ui-state-disabled" );
292 |
293 | // clean up events and states
294 | this.bindings.unbind( this.eventNamespace );
295 | this.hoverable.removeClass( "ui-state-hover" );
296 | this.focusable.removeClass( "ui-state-focus" );
297 | },
298 | _destroy: $.noop,
299 |
300 | widget: function() {
301 | return this.element;
302 | },
303 |
304 | option: function( key, value ) {
305 | var options = key,
306 | parts,
307 | curOption,
308 | i;
309 |
310 | if ( arguments.length === 0 ) {
311 | // don't return a reference to the internal hash
312 | return $.widget.extend( {}, this.options );
313 | }
314 |
315 | if ( typeof key === "string" ) {
316 | // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
317 | options = {};
318 | parts = key.split( "." );
319 | key = parts.shift();
320 | if ( parts.length ) {
321 | curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
322 | for ( i = 0; i < parts.length - 1; i++ ) {
323 | curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
324 | curOption = curOption[ parts[ i ] ];
325 | }
326 | key = parts.pop();
327 | if ( value === undefined ) {
328 | return curOption[ key ] === undefined ? null : curOption[ key ];
329 | }
330 | curOption[ key ] = value;
331 | } else {
332 | if ( value === undefined ) {
333 | return this.options[ key ] === undefined ? null : this.options[ key ];
334 | }
335 | options[ key ] = value;
336 | }
337 | }
338 |
339 | this._setOptions( options );
340 |
341 | return this;
342 | },
343 | _setOptions: function( options ) {
344 | var key;
345 |
346 | for ( key in options ) {
347 | this._setOption( key, options[ key ] );
348 | }
349 |
350 | return this;
351 | },
352 | _setOption: function( key, value ) {
353 | this.options[ key ] = value;
354 |
355 | if ( key === "disabled" ) {
356 | this.widget()
357 | .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
358 | .attr( "aria-disabled", value );
359 | this.hoverable.removeClass( "ui-state-hover" );
360 | this.focusable.removeClass( "ui-state-focus" );
361 | }
362 |
363 | return this;
364 | },
365 |
366 | enable: function() {
367 | return this._setOption( "disabled", false );
368 | },
369 | disable: function() {
370 | return this._setOption( "disabled", true );
371 | },
372 |
373 | _on: function( suppressDisabledCheck, element, handlers ) {
374 | var delegateElement,
375 | instance = this;
376 |
377 | // no suppressDisabledCheck flag, shuffle arguments
378 | if ( typeof suppressDisabledCheck !== "boolean" ) {
379 | handlers = element;
380 | element = suppressDisabledCheck;
381 | suppressDisabledCheck = false;
382 | }
383 |
384 | // no element argument, shuffle and use this.element
385 | if ( !handlers ) {
386 | handlers = element;
387 | element = this.element;
388 | delegateElement = this.widget();
389 | } else {
390 | // accept selectors, DOM elements
391 | element = delegateElement = $( element );
392 | this.bindings = this.bindings.add( element );
393 | }
394 |
395 | $.each( handlers, function( event, handler ) {
396 | function handlerProxy() {
397 | // allow widgets to customize the disabled handling
398 | // - disabled as an array instead of boolean
399 | // - disabled class as method for disabling individual parts
400 | if ( !suppressDisabledCheck &&
401 | ( instance.options.disabled === true ||
402 | $( this ).hasClass( "ui-state-disabled" ) ) ) {
403 | return;
404 | }
405 | return ( typeof handler === "string" ? instance[ handler ] : handler )
406 | .apply( instance, arguments );
407 | }
408 |
409 | // copy the guid so direct unbinding works
410 | if ( typeof handler !== "string" ) {
411 | handlerProxy.guid = handler.guid =
412 | handler.guid || handlerProxy.guid || $.guid++;
413 | }
414 |
415 | var match = event.match( /^(\w+)\s*(.*)$/ ),
416 | eventName = match[1] + instance.eventNamespace,
417 | selector = match[2];
418 | if ( selector ) {
419 | delegateElement.delegate( selector, eventName, handlerProxy );
420 | } else {
421 | element.bind( eventName, handlerProxy );
422 | }
423 | });
424 | },
425 |
426 | _off: function( element, eventName ) {
427 | eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
428 | element.unbind( eventName ).undelegate( eventName );
429 | },
430 |
431 | _delay: function( handler, delay ) {
432 | function handlerProxy() {
433 | return ( typeof handler === "string" ? instance[ handler ] : handler )
434 | .apply( instance, arguments );
435 | }
436 | var instance = this;
437 | return setTimeout( handlerProxy, delay || 0 );
438 | },
439 |
440 | _hoverable: function( element ) {
441 | this.hoverable = this.hoverable.add( element );
442 | this._on( element, {
443 | mouseenter: function( event ) {
444 | $( event.currentTarget ).addClass( "ui-state-hover" );
445 | },
446 | mouseleave: function( event ) {
447 | $( event.currentTarget ).removeClass( "ui-state-hover" );
448 | }
449 | });
450 | },
451 |
452 | _focusable: function( element ) {
453 | this.focusable = this.focusable.add( element );
454 | this._on( element, {
455 | focusin: function( event ) {
456 | $( event.currentTarget ).addClass( "ui-state-focus" );
457 | },
458 | focusout: function( event ) {
459 | $( event.currentTarget ).removeClass( "ui-state-focus" );
460 | }
461 | });
462 | },
463 |
464 | _trigger: function( type, event, data ) {
465 | var prop, orig,
466 | callback = this.options[ type ];
467 |
468 | data = data || {};
469 | event = $.Event( event );
470 | event.type = ( type === this.widgetEventPrefix ?
471 | type :
472 | this.widgetEventPrefix + type ).toLowerCase();
473 | // the original event may come from any element
474 | // so we need to reset the target on the new event
475 | event.target = this.element[ 0 ];
476 |
477 | // copy original event properties over to the new event
478 | orig = event.originalEvent;
479 | if ( orig ) {
480 | for ( prop in orig ) {
481 | if ( !( prop in event ) ) {
482 | event[ prop ] = orig[ prop ];
483 | }
484 | }
485 | }
486 |
487 | this.element.trigger( event, data );
488 | return !( $.isFunction( callback ) &&
489 | callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
490 | event.isDefaultPrevented() );
491 | }
492 | };
493 |
494 | $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
495 | $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
496 | if ( typeof options === "string" ) {
497 | options = { effect: options };
498 | }
499 | var hasOptions,
500 | effectName = !options ?
501 | method :
502 | options === true || typeof options === "number" ?
503 | defaultEffect :
504 | options.effect || defaultEffect;
505 | options = options || {};
506 | if ( typeof options === "number" ) {
507 | options = { duration: options };
508 | }
509 | hasOptions = !$.isEmptyObject( options );
510 | options.complete = callback;
511 | if ( options.delay ) {
512 | element.delay( options.delay );
513 | }
514 | if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
515 | element[ method ]( options );
516 | } else if ( effectName !== method && element[ effectName ] ) {
517 | element[ effectName ]( options.duration, options.easing, callback );
518 | } else {
519 | element.queue(function( next ) {
520 | $( this )[ method ]();
521 | if ( callback ) {
522 | callback.call( element[ 0 ] );
523 | }
524 | next();
525 | });
526 | }
527 | };
528 | });
529 |
530 | }));
531 |
--------------------------------------------------------------------------------
/sample/vendor/js/underscore-1.4.4.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | var n = this,
3 | t = n._,
4 | r = {}, e = Array.prototype,
5 | u = Object.prototype,
6 | i = Function.prototype,
7 | a = e.push,
8 | o = e.slice,
9 | c = e.concat,
10 | l = u.toString,
11 | f = u.hasOwnProperty,
12 | s = e.forEach,
13 | p = e.map,
14 | h = e.reduce,
15 | v = e.reduceRight,
16 | d = e.filter,
17 | g = e.every,
18 | m = e.some,
19 | y = e.indexOf,
20 | b = e.lastIndexOf,
21 | x = Array.isArray,
22 | _ = Object.keys,
23 | j = i.bind,
24 | w = function (n) {
25 | return n instanceof w ? n : this instanceof w ? (this._wrapped = n, void 0) : new w(n)
26 | };
27 | "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = w), exports._ = w) : n._ = w, w.VERSION = "1.4.4";
28 | var A = w.each = w.forEach = function (n, t, e) {
29 | if (null != n)
30 | if (s && n.forEach === s) n.forEach(t, e);
31 | else if (n.length === +n.length) {
32 | for (var u = 0, i = n.length; i > u; u++)
33 | if (t.call(e, n[u], u, n) === r) return
34 | } else
35 | for (var a in n)
36 | if (w.has(n, a) && t.call(e, n[a], a, n) === r) return
37 | };
38 | w.map = w.collect = function (n, t, r) {
39 | var e = [];
40 | return null == n ? e : p && n.map === p ? n.map(t, r) : (A(n, function (n, u, i) {
41 | e[e.length] = t.call(r, n, u, i)
42 | }), e)
43 | };
44 | var O = "Reduce of empty array with no initial value";
45 | w.reduce = w.foldl = w.inject = function (n, t, r, e) {
46 | var u = arguments.length > 2;
47 | if (null == n && (n = []), h && n.reduce === h) return e && (t = w.bind(t, e)), u ? n.reduce(t, r) : n.reduce(t);
48 | if (A(n, function (n, i, a) {
49 | u ? r = t.call(e, r, n, i, a) : (r = n, u = !0)
50 | }), !u) throw new TypeError(O);
51 | return r
52 | }, w.reduceRight = w.foldr = function (n, t, r, e) {
53 | var u = arguments.length > 2;
54 | if (null == n && (n = []), v && n.reduceRight === v) return e && (t = w.bind(t, e)), u ? n.reduceRight(t, r) : n.reduceRight(t);
55 | var i = n.length;
56 | if (i !== +i) {
57 | var a = w.keys(n);
58 | i = a.length
59 | }
60 | if (A(n, function (o, c, l) {
61 | c = a ? a[--i] : --i, u ? r = t.call(e, r, n[c], c, l) : (r = n[c], u = !0)
62 | }), !u) throw new TypeError(O);
63 | return r
64 | }, w.find = w.detect = function (n, t, r) {
65 | var e;
66 | return E(n, function (n, u, i) {
67 | return t.call(r, n, u, i) ? (e = n, !0) : void 0
68 | }), e
69 | }, w.filter = w.select = function (n, t, r) {
70 | var e = [];
71 | return null == n ? e : d && n.filter === d ? n.filter(t, r) : (A(n, function (n, u, i) {
72 | t.call(r, n, u, i) && (e[e.length] = n)
73 | }), e)
74 | }, w.reject = function (n, t, r) {
75 | return w.filter(n, function (n, e, u) {
76 | return !t.call(r, n, e, u)
77 | }, r)
78 | }, w.every = w.all = function (n, t, e) {
79 | t || (t = w.identity);
80 | var u = !0;
81 | return null == n ? u : g && n.every === g ? n.every(t, e) : (A(n, function (n, i, a) {
82 | return (u = u && t.call(e, n, i, a)) ? void 0 : r
83 | }), !! u)
84 | };
85 | var E = w.some = w.any = function (n, t, e) {
86 | t || (t = w.identity);
87 | var u = !1;
88 | return null == n ? u : m && n.some === m ? n.some(t, e) : (A(n, function (n, i, a) {
89 | return u || (u = t.call(e, n, i, a)) ? r : void 0
90 | }), !! u)
91 | };
92 | w.contains = w.include = function (n, t) {
93 | return null == n ? !1 : y && n.indexOf === y ? n.indexOf(t) != -1 : E(n, function (n) {
94 | return n === t
95 | })
96 | }, w.invoke = function (n, t) {
97 | var r = o.call(arguments, 2),
98 | e = w.isFunction(t);
99 | return w.map(n, function (n) {
100 | return (e ? t : n[t]).apply(n, r)
101 | })
102 | }, w.pluck = function (n, t) {
103 | return w.map(n, function (n) {
104 | return n[t]
105 | })
106 | }, w.where = function (n, t, r) {
107 | return w.isEmpty(t) ? r ? null : [] : w[r ? "find" : "filter"](n, function (n) {
108 | for (var r in t)
109 | if (t[r] !== n[r]) return !1;
110 | return !0
111 | })
112 | }, w.findWhere = function (n, t) {
113 | return w.where(n, t, !0)
114 | }, w.max = function (n, t, r) {
115 | if (!t && w.isArray(n) && n[0] === +n[0] && 65535 > n.length) return Math.max.apply(Math, n);
116 | if (!t && w.isEmpty(n)) return -1 / 0;
117 | var e = {
118 | computed: -1 / 0,
119 | value: -1 / 0
120 | };
121 | return A(n, function (n, u, i) {
122 | var a = t ? t.call(r, n, u, i) : n;
123 | a >= e.computed && (e = {
124 | value: n,
125 | computed: a
126 | })
127 | }), e.value
128 | }, w.min = function (n, t, r) {
129 | if (!t && w.isArray(n) && n[0] === +n[0] && 65535 > n.length) return Math.min.apply(Math, n);
130 | if (!t && w.isEmpty(n)) return 1 / 0;
131 | var e = {
132 | computed: 1 / 0,
133 | value: 1 / 0
134 | };
135 | return A(n, function (n, u, i) {
136 | var a = t ? t.call(r, n, u, i) : n;
137 | e.computed > a && (e = {
138 | value: n,
139 | computed: a
140 | })
141 | }), e.value
142 | }, w.shuffle = function (n) {
143 | var t, r = 0,
144 | e = [];
145 | return A(n, function (n) {
146 | t = w.random(r++), e[r - 1] = e[t], e[t] = n
147 | }), e
148 | };
149 | var k = function (n) {
150 | return w.isFunction(n) ? n : function (t) {
151 | return t[n]
152 | }
153 | };
154 | w.sortBy = function (n, t, r) {
155 | var e = k(t);
156 | return w.pluck(w.map(n, function (n, t, u) {
157 | return {
158 | value: n,
159 | index: t,
160 | criteria: e.call(r, n, t, u)
161 | }
162 | }).sort(function (n, t) {
163 | var r = n.criteria,
164 | e = t.criteria;
165 | if (r !== e) {
166 | if (r > e || r === void 0) return 1;
167 | if (e > r || e === void 0) return -1
168 | }
169 | return n.index < t.index ? -1 : 1
170 | }), "value")
171 | };
172 | var F = function (n, t, r, e) {
173 | var u = {}, i = k(t || w.identity);
174 | return A(n, function (t, a) {
175 | var o = i.call(r, t, a, n);
176 | e(u, o, t)
177 | }), u
178 | };
179 | w.groupBy = function (n, t, r) {
180 | return F(n, t, r, function (n, t, r) {
181 | (w.has(n, t) ? n[t] : n[t] = []).push(r)
182 | })
183 | }, w.countBy = function (n, t, r) {
184 | return F(n, t, r, function (n, t) {
185 | w.has(n, t) || (n[t] = 0), n[t]++
186 | })
187 | }, w.sortedIndex = function (n, t, r, e) {
188 | r = null == r ? w.identity : k(r);
189 | for (var u = r.call(e, t), i = 0, a = n.length; a > i;) {
190 | var o = i + a >>> 1;
191 | u > r.call(e, n[o]) ? i = o + 1 : a = o
192 | }
193 | return i
194 | }, w.toArray = function (n) {
195 | return n ? w.isArray(n) ? o.call(n) : n.length === +n.length ? w.map(n, w.identity) : w.values(n) : []
196 | }, w.size = function (n) {
197 | return null == n ? 0 : n.length === +n.length ? n.length : w.keys(n).length
198 | }, w.first = w.head = w.take = function (n, t, r) {
199 | return null == n ? void 0 : null == t || r ? n[0] : o.call(n, 0, t)
200 | }, w.initial = function (n, t, r) {
201 | return o.call(n, 0, n.length - (null == t || r ? 1 : t))
202 | }, w.last = function (n, t, r) {
203 | return null == n ? void 0 : null == t || r ? n[n.length - 1] : o.call(n, Math.max(n.length - t, 0))
204 | }, w.rest = w.tail = w.drop = function (n, t, r) {
205 | return o.call(n, null == t || r ? 1 : t)
206 | }, w.compact = function (n) {
207 | return w.filter(n, w.identity)
208 | };
209 | var R = function (n, t, r) {
210 | return A(n, function (n) {
211 | w.isArray(n) ? t ? a.apply(r, n) : R(n, t, r) : r.push(n)
212 | }), r
213 | };
214 | w.flatten = function (n, t) {
215 | return R(n, t, [])
216 | }, w.without = function (n) {
217 | return w.difference(n, o.call(arguments, 1))
218 | }, w.uniq = w.unique = function (n, t, r, e) {
219 | w.isFunction(t) && (e = r, r = t, t = !1);
220 | var u = r ? w.map(n, r, e) : n,
221 | i = [],
222 | a = [];
223 | return A(u, function (r, e) {
224 | (t ? e && a[a.length - 1] === r : w.contains(a, r)) || (a.push(r), i.push(n[e]))
225 | }), i
226 | }, w.union = function () {
227 | return w.uniq(c.apply(e, arguments))
228 | }, w.intersection = function (n) {
229 | var t = o.call(arguments, 1);
230 | return w.filter(w.uniq(n), function (n) {
231 | return w.every(t, function (t) {
232 | return w.indexOf(t, n) >= 0
233 | })
234 | })
235 | }, w.difference = function (n) {
236 | var t = c.apply(e, o.call(arguments, 1));
237 | return w.filter(n, function (n) {
238 | return !w.contains(t, n)
239 | })
240 | }, w.zip = function () {
241 | for (var n = o.call(arguments), t = w.max(w.pluck(n, "length")), r = Array(t), e = 0; t > e; e++) r[e] = w.pluck(n, "" + e);
242 | return r
243 | }, w.object = function (n, t) {
244 | if (null == n) return {};
245 | for (var r = {}, e = 0, u = n.length; u > e; e++) t ? r[n[e]] = t[e] : r[n[e][0]] = n[e][1];
246 | return r
247 | }, w.indexOf = function (n, t, r) {
248 | if (null == n) return -1;
249 | var e = 0,
250 | u = n.length;
251 | if (r) {
252 | if ("number" != typeof r) return e = w.sortedIndex(n, t), n[e] === t ? e : -1;
253 | e = 0 > r ? Math.max(0, u + r) : r
254 | }
255 | if (y && n.indexOf === y) return n.indexOf(t, r);
256 | for (; u > e; e++)
257 | if (n[e] === t) return e;
258 | return -1
259 | }, w.lastIndexOf = function (n, t, r) {
260 | if (null == n) return -1;
261 | var e = null != r;
262 | if (b && n.lastIndexOf === b) return e ? n.lastIndexOf(t, r) : n.lastIndexOf(t);
263 | for (var u = e ? r : n.length; u--;)
264 | if (n[u] === t) return u;
265 | return -1
266 | }, w.range = function (n, t, r) {
267 | 1 >= arguments.length && (t = n || 0, n = 0), r = arguments[2] || 1;
268 | for (var e = Math.max(Math.ceil((t - n) / r), 0), u = 0, i = Array(e); e > u;) i[u++] = n, n += r;
269 | return i
270 | }, w.bind = function (n, t) {
271 | if (n.bind === j && j) return j.apply(n, o.call(arguments, 1));
272 | var r = o.call(arguments, 2);
273 | return function () {
274 | return n.apply(t, r.concat(o.call(arguments)))
275 | }
276 | }, w.partial = function (n) {
277 | var t = o.call(arguments, 1);
278 | return function () {
279 | return n.apply(this, t.concat(o.call(arguments)))
280 | }
281 | }, w.bindAll = function (n) {
282 | var t = o.call(arguments, 1);
283 | return 0 === t.length && (t = w.functions(n)), A(t, function (t) {
284 | n[t] = w.bind(n[t], n)
285 | }), n
286 | }, w.memoize = function (n, t) {
287 | var r = {};
288 | return t || (t = w.identity),
289 | function () {
290 | var e = t.apply(this, arguments);
291 | return w.has(r, e) ? r[e] : r[e] = n.apply(this, arguments)
292 | }
293 | }, w.delay = function (n, t) {
294 | var r = o.call(arguments, 2);
295 | return setTimeout(function () {
296 | return n.apply(null, r)
297 | }, t)
298 | }, w.defer = function (n) {
299 | return w.delay.apply(w, [n, 1].concat(o.call(arguments, 1)))
300 | }, w.throttle = function (n, t) {
301 | var r, e, u, i, a = 0,
302 | o = function () {
303 | a = new Date, u = null, i = n.apply(r, e)
304 | };
305 | return function () {
306 | var c = new Date,
307 | l = t - (c - a);
308 | return r = this, e = arguments, 0 >= l ? (clearTimeout(u), u = null, a = c, i = n.apply(r, e)) : u || (u = setTimeout(o, l)), i
309 | }
310 | }, w.debounce = function (n, t, r) {
311 | var e, u;
312 | return function () {
313 | var i = this,
314 | a = arguments,
315 | o = function () {
316 | e = null, r || (u = n.apply(i, a))
317 | }, c = r && !e;
318 | return clearTimeout(e), e = setTimeout(o, t), c && (u = n.apply(i, a)), u
319 | }
320 | }, w.once = function (n) {
321 | var t, r = !1;
322 | return function () {
323 | return r ? t : (r = !0, t = n.apply(this, arguments), n = null, t)
324 | }
325 | }, w.wrap = function (n, t) {
326 | return function () {
327 | var r = [n];
328 | return a.apply(r, arguments), t.apply(this, r)
329 | }
330 | }, w.compose = function () {
331 | var n = arguments;
332 | return function () {
333 | for (var t = arguments, r = n.length - 1; r >= 0; r--) t = [n[r].apply(this, t)];
334 | return t[0]
335 | }
336 | }, w.after = function (n, t) {
337 | return 0 >= n ? t() : function () {
338 | return 1 > --n ? t.apply(this, arguments) : void 0
339 | }
340 | }, w.keys = _ || function (n) {
341 | if (n !== Object(n)) throw new TypeError("Invalid object");
342 | var t = [];
343 | for (var r in n) w.has(n, r) && (t[t.length] = r);
344 | return t
345 | }, w.values = function (n) {
346 | var t = [];
347 | for (var r in n) w.has(n, r) && t.push(n[r]);
348 | return t
349 | }, w.pairs = function (n) {
350 | var t = [];
351 | for (var r in n) w.has(n, r) && t.push([r, n[r]]);
352 | return t
353 | }, w.invert = function (n) {
354 | var t = {};
355 | for (var r in n) w.has(n, r) && (t[n[r]] = r);
356 | return t
357 | }, w.functions = w.methods = function (n) {
358 | var t = [];
359 | for (var r in n) w.isFunction(n[r]) && t.push(r);
360 | return t.sort()
361 | }, w.extend = function (n) {
362 | return A(o.call(arguments, 1), function (t) {
363 | if (t)
364 | for (var r in t) n[r] = t[r]
365 | }), n
366 | }, w.pick = function (n) {
367 | var t = {}, r = c.apply(e, o.call(arguments, 1));
368 | return A(r, function (r) {
369 | r in n && (t[r] = n[r])
370 | }), t
371 | }, w.omit = function (n) {
372 | var t = {}, r = c.apply(e, o.call(arguments, 1));
373 | for (var u in n) w.contains(r, u) || (t[u] = n[u]);
374 | return t
375 | }, w.defaults = function (n) {
376 | return A(o.call(arguments, 1), function (t) {
377 | if (t)
378 | for (var r in t) null == n[r] && (n[r] = t[r])
379 | }), n
380 | }, w.clone = function (n) {
381 | return w.isObject(n) ? w.isArray(n) ? n.slice() : w.extend({}, n) : n
382 | }, w.tap = function (n, t) {
383 | return t(n), n
384 | };
385 | var I = function (n, t, r, e) {
386 | if (n === t) return 0 !== n || 1 / n == 1 / t;
387 | if (null == n || null == t) return n === t;
388 | n instanceof w && (n = n._wrapped), t instanceof w && (t = t._wrapped);
389 | var u = l.call(n);
390 | if (u != l.call(t)) return !1;
391 | switch (u) {
392 | case "[object String]":
393 | return n == t + "";
394 | case "[object Number]":
395 | return n != +n ? t != +t : 0 == n ? 1 / n == 1 / t : n == +t;
396 | case "[object Date]":
397 | case "[object Boolean]":
398 | return +n == +t;
399 | case "[object RegExp]":
400 | return n.source == t.source && n.global == t.global && n.multiline == t.multiline && n.ignoreCase == t.ignoreCase
401 | }
402 | if ("object" != typeof n || "object" != typeof t) return !1;
403 | for (var i = r.length; i--;)
404 | if (r[i] == n) return e[i] == t;
405 | r.push(n), e.push(t);
406 | var a = 0,
407 | o = !0;
408 | if ("[object Array]" == u) {
409 | if (a = n.length, o = a == t.length)
410 | for (; a-- && (o = I(n[a], t[a], r, e)););
411 | } else {
412 | var c = n.constructor,
413 | f = t.constructor;
414 | if (c !== f && !(w.isFunction(c) && c instanceof c && w.isFunction(f) && f instanceof f)) return !1;
415 | for (var s in n)
416 | if (w.has(n, s) && (a++, !(o = w.has(t, s) && I(n[s], t[s], r, e)))) break;
417 | if (o) {
418 | for (s in t)
419 | if (w.has(t, s) && !a--) break;
420 | o = !a
421 | }
422 | }
423 | return r.pop(), e.pop(), o
424 | };
425 | w.isEqual = function (n, t) {
426 | return I(n, t, [], [])
427 | }, w.isEmpty = function (n) {
428 | if (null == n) return !0;
429 | if (w.isArray(n) || w.isString(n)) return 0 === n.length;
430 | for (var t in n)
431 | if (w.has(n, t)) return !1;
432 | return !0
433 | }, w.isElement = function (n) {
434 | return !(!n || 1 !== n.nodeType)
435 | }, w.isArray = x || function (n) {
436 | return "[object Array]" == l.call(n)
437 | }, w.isObject = function (n) {
438 | return n === Object(n)
439 | }, A(["Arguments", "Function", "String", "Number", "Date", "RegExp"], function (n) {
440 | w["is" + n] = function (t) {
441 | return l.call(t) == "[object " + n + "]"
442 | }
443 | }), w.isArguments(arguments) || (w.isArguments = function (n) {
444 | return !(!n || !w.has(n, "callee"))
445 | }), "function" != typeof / . / && (w.isFunction = function (n) {
446 | return "function" == typeof n
447 | }), w.isFinite = function (n) {
448 | return isFinite(n) && !isNaN(parseFloat(n))
449 | }, w.isNaN = function (n) {
450 | return w.isNumber(n) && n != +n
451 | }, w.isBoolean = function (n) {
452 | return n === !0 || n === !1 || "[object Boolean]" == l.call(n)
453 | }, w.isNull = function (n) {
454 | return null === n
455 | }, w.isUndefined = function (n) {
456 | return n === void 0
457 | }, w.has = function (n, t) {
458 | return f.call(n, t)
459 | }, w.noConflict = function () {
460 | return n._ = t, this
461 | }, w.identity = function (n) {
462 | return n
463 | }, w.times = function (n, t, r) {
464 | for (var e = Array(n), u = 0; n > u; u++) e[u] = t.call(r, u);
465 | return e
466 | }, w.random = function (n, t) {
467 | return null == t && (t = n, n = 0), n + Math.floor(Math.random() * (t - n + 1))
468 | };
469 | var M = {
470 | escape: {
471 | "&": "&",
472 | "<": "<",
473 | ">": ">",
474 | '"': """,
475 | "'": "'",
476 | "/": "/"
477 | }
478 | };
479 | M.unescape = w.invert(M.escape);
480 | var S = {
481 | escape: RegExp("[" + w.keys(M.escape).join("") + "]", "g"),
482 | unescape: RegExp("(" + w.keys(M.unescape).join("|") + ")", "g")
483 | };
484 | w.each(["escape", "unescape"], function (n) {
485 | w[n] = function (t) {
486 | return null == t ? "" : ("" + t).replace(S[n], function (t) {
487 | return M[n][t]
488 | })
489 | }
490 | }), w.result = function (n, t) {
491 | if (null == n) return null;
492 | var r = n[t];
493 | return w.isFunction(r) ? r.call(n) : r
494 | }, w.mixin = function (n) {
495 | A(w.functions(n), function (t) {
496 | var r = w[t] = n[t];
497 | w.prototype[t] = function () {
498 | var n = [this._wrapped];
499 | return a.apply(n, arguments), D.call(this, r.apply(w, n))
500 | }
501 | })
502 | };
503 | var N = 0;
504 | w.uniqueId = function (n) {
505 | var t = ++N + "";
506 | return n ? n + t : t
507 | }, w.templateSettings = {
508 | evaluate: /<%([\s\S]+?)%>/g,
509 | interpolate: /<%=([\s\S]+?)%>/g,
510 | escape: /<%-([\s\S]+?)%>/g
511 | };
512 | var T = /(.)^/,
513 | q = {
514 | "'": "'",
515 | "\\": "\\",
516 | "\r": "r",
517 | "\n": "n",
518 | " ": "t",
519 | "\u2028": "u2028",
520 | "\u2029": "u2029"
521 | }, B = /\\|'|\r|\n|\t|\u2028|\u2029/g;
522 | w.template = function (n, t, r) {
523 | var e;
524 | r = w.defaults({}, r, w.templateSettings);
525 | var u = RegExp([(r.escape || T).source, (r.interpolate || T).source, (r.evaluate || T).source].join("|") + "|$", "g"),
526 | i = 0,
527 | a = "__p+='";
528 | n.replace(u, function (t, r, e, u, o) {
529 | return a += n.slice(i, o).replace(B, function (n) {
530 | return "\\" + q[n]
531 | }), r && (a += "'+\n((__t=(" + r + "))==null?'':_.escape(__t))+\n'"), e && (a += "'+\n((__t=(" + e + "))==null?'':__t)+\n'"), u && (a += "';\n" + u + "\n__p+='"), i = o + t.length, t
532 | }), a += "';\n", r.variable || (a = "with(obj||{}){\n" + a + "}\n"), a = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + a + "return __p;\n";
533 | try {
534 | e = Function(r.variable || "obj", "_", a)
535 | } catch (o) {
536 | throw o.source = a, o
537 | }
538 | if (t) return e(t, w);
539 | var c = function (n) {
540 | return e.call(this, n, w)
541 | };
542 | return c.source = "function(" + (r.variable || "obj") + "){\n" + a + "}", c
543 | }, w.chain = function (n) {
544 | return w(n).chain()
545 | };
546 | var D = function (n) {
547 | return this._chain ? w(n).chain() : n
548 | };
549 | w.mixin(w), A(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function (n) {
550 | var t = e[n];
551 | w.prototype[n] = function () {
552 | var r = this._wrapped;
553 | return t.apply(r, arguments), "shift" != n && "splice" != n || 0 !== r.length || delete r[0], D.call(this, r)
554 | }
555 | }), A(["concat", "join", "slice"], function (n) {
556 | var t = e[n];
557 | w.prototype[n] = function () {
558 | return D.call(this, t.apply(this._wrapped, arguments))
559 | }
560 | }), w.extend(w.prototype, {
561 | chain: function () {
562 | return this._chain = !0, this
563 | },
564 | value: function () {
565 | return this._wrapped
566 | }
567 | })
568 | }).call(this);
--------------------------------------------------------------------------------
/templates/upload-manager.file:
--------------------------------------------------------------------------------
1 |
<%= name %>
2 |
3 |
<%= displaySize(size) %>
4 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/templates/upload-manager.main:
--------------------------------------------------------------------------------
1 |
Upload files
2 |
5 |
--------------------------------------------------------------------------------