sunrise-core 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. data/README.rdoc +2 -2
  2. data/app/controllers/manage/assets_controller.rb +2 -2
  3. data/app/views/layouts/manage.html.erb +4 -5
  4. data/app/views/manage/{assets/_picture.html.erb → fileupload/_asset.html.erb} +4 -3
  5. data/app/views/manage/fileupload/_container.html.erb +25 -0
  6. data/app/views/manage/fileupload/_tmpl.html.erb +14 -0
  7. data/app/views/manage/users/_form.html.erb +5 -1
  8. data/app/views/manage/users/_model_filter.html.erb +5 -3
  9. data/config/locales/manage/en.yml +5 -0
  10. data/config/locales/manage/ru.yml +5 -0
  11. data/config/locales/manage/uk.yml +5 -0
  12. data/lib/generators/sunrise/install_generator.rb +26 -6
  13. data/lib/generators/sunrise/templates/helpers/manage/assets_helper.rb +0 -14
  14. data/lib/generators/sunrise/templates/javascripts/manage-fileuploader.js +182 -0
  15. data/lib/generators/sunrise/templates/javascripts/manage.js +17 -13
  16. data/lib/generators/sunrise/templates/models/defaults/user.rb +1 -5
  17. data/lib/generators/sunrise/templates/stylesheets/manage/buttons.css +42 -0
  18. data/lib/generators/sunrise/templates/stylesheets/manage/main.css +11 -0
  19. data/lib/generators/sunrise/templates/stylesheets/smoothness/{jquery-ui-1.8.6.custom.css → jquery-ui-1.8.13.custom.css} +37 -31
  20. data/lib/sunrise/engine.rb +5 -0
  21. data/lib/sunrise/models/asset.rb +1 -1
  22. data/lib/sunrise/version.rb +1 -1
  23. data/lib/sunrise/views/form_builder.rb +53 -6
  24. metadata +56 -43
  25. data/app/views/manage/assets/_collection.html.erb +0 -32
  26. data/app/views/manage/assets/_swfscript.html.erb +0 -51
  27. data/lib/generators/sunrise/templates/javascripts/swfupload/fileprogress.js +0 -114
  28. data/lib/generators/sunrise/templates/javascripts/swfupload/handlers.js +0 -164
  29. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.js +0 -1134
  30. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.queue.js +0 -98
  31. data/lib/generators/sunrise/templates/javascripts/swfupload/swfupload.swf +0 -0
@@ -1,114 +0,0 @@
1
- /* ******************************************
2
- * FileProgress Object
3
- * Control object for displaying file info
4
- * ****************************************** */
5
-
6
- function FileProgress(file, targetID) {
7
- this.fileProgressID = "divFileProgress";
8
-
9
- this.fileProgressWrapper = document.getElementById(this.fileProgressID);
10
- if (!this.fileProgressWrapper) {
11
- this.fileProgressWrapper = document.createElement("div");
12
- this.fileProgressWrapper.className = "progress-container";
13
- this.fileProgressWrapper.id = this.fileProgressID;
14
-
15
- var progressStatus = document.createElement("div");
16
- progressStatus.className = "status-message";
17
- progressStatus.innerHTML = " ";
18
-
19
- this.fileProgressElement = document.createElement("div");
20
- this.fileProgressElement.className = "progress-bar";
21
-
22
- var progressBar = document.createElement("div");
23
- progressBar.className = "progress";
24
-
25
- this.fileProgressElement.appendChild(progressBar);
26
-
27
- this.fileProgressWrapper.appendChild(progressStatus);
28
- this.fileProgressWrapper.appendChild(this.fileProgressElement);
29
-
30
- document.getElementById(targetID).appendChild(this.fileProgressWrapper);
31
-
32
- } else {
33
- this.fileProgressElement = this.fileProgressWrapper.childNodes[1];
34
- //this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
35
- }
36
-
37
- this.height = this.fileProgressWrapper.offsetHeight;
38
- }
39
- FileProgress.prototype.setProgress = function(percentage) {
40
- var value = parseInt((400 * percentage / 100));
41
- this.fileProgressElement.childNodes[0].style.width = value + "px";
42
- };
43
- FileProgress.prototype.setComplete = function() {
44
- /*this.fileProgressElement.className = "progressContainer blue";
45
- this.fileProgressElement.childNodes[3].className = "progressBarComplete";
46
- this.fileProgressElement.childNodes[3].style.width = "";*/
47
-
48
- };
49
- FileProgress.prototype.setError = function() {
50
- /*this.fileProgressElement.className = "progressContainer red";
51
- this.fileProgressElement.childNodes[3].className = "progressBarError";
52
- this.fileProgressElement.childNodes[3].style.width = "";*/
53
-
54
- };
55
- FileProgress.prototype.setCancelled = function() {
56
- /*this.fileProgressElement.className = "progressContainer";
57
- this.fileProgressElement.childNodes[3].className = "progressBarError";
58
- this.fileProgressElement.childNodes[3].style.width = "";*/
59
-
60
- };
61
- FileProgress.prototype.setStatus = function(status) {
62
- this.fileProgressWrapper.childNodes[0].innerHTML = status;
63
- };
64
- FileProgress.prototype.parseXML = function(xml){
65
- var xmlDoc = null;
66
-
67
- if (window.ActiveXObject)
68
- {
69
- xmlDoc = Ajax.getTransport();
70
- xmlDoc.async = false;
71
- xmlDoc.loadXML(xml);
72
- }
73
- else
74
- {
75
- var parser = new DOMParser();
76
- xmlDoc = parser.parseFromString(xml,"text/xml");
77
- }
78
-
79
- return xmlDoc;
80
- };
81
- FileProgress.prototype.setThumbnail = function(serverData, collection_id) {
82
- var xml = this.parseXML(serverData);
83
- var thumbnail = xml.getElementsByTagName('asset');
84
- var collection = document.getElementById(collection_id);
85
-
86
- thumbnail = (thumbnail[0] == null ? xml : thumbnail[0])
87
-
88
- if (thumbnail != null)
89
- {
90
- var id_node = thumbnail.getElementsByTagName('id')[0];
91
- var filename_node = thumbnail.getElementsByTagName('filename')[0];
92
- var styles_node = thumbnail.getElementsByTagName('styles')[0];
93
- var thumb_node = styles_node ? styles_node.getElementsByTagName('thumb')[0] : thumbnail.getElementsByTagName('thumb')[0];
94
-
95
- var id = id_node.childNodes[0].nodeValue;
96
- var filename = filename_node.childNodes[0].nodeValue;
97
- var thumb = thumb_node.childNodes[0].nodeValue;
98
-
99
- var picture = { id: id, link_path: thumb, image_path: thumb, image_title: filename };
100
-
101
- $("#asset_tmpl").tmpl(picture).appendTo( collection );
102
- }
103
- };
104
-
105
- FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
106
- /*this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
107
- if (swfuploadInstance) {
108
- var fileID = this.fileProgressID;
109
- this.fileProgressElement.childNodes[0].onclick = function () {
110
- swfuploadInstance.cancelUpload(fileID);
111
- return false;
112
- };
113
- }*/
114
- };
@@ -1,164 +0,0 @@
1
- function uploadStart(file) {
2
- try {
3
- var progress = new FileProgress(file, this.customSettings.progressTarget);
4
- progress.setStatus("Загрузка...");
5
- progress.setProgress(0);
6
- progress.toggleCancel(true, this);
7
- }
8
- catch (ex) {}
9
-
10
- return true;
11
- }
12
-
13
- function fileQueued(file) {
14
- try {
15
- var progress = new FileProgress(file, this.customSettings.progressTarget);
16
- progress.setStatus("Подготовка...");
17
- progress.setProgress(0);
18
- progress.toggleCancel(true, this);
19
- } catch (ex) {
20
- this.debug(ex);
21
- }
22
- }
23
-
24
- function fileQueueError(file, errorCode, message) {
25
- try {
26
- if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
27
- alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
28
- return;
29
- }
30
-
31
- var progress = new FileProgress(file, this.customSettings.progressTarget);
32
- progress.setError();
33
- progress.toggleCancel(false);
34
-
35
- switch (errorCode) {
36
- case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
37
- progress.setStatus("File is too big.");
38
- this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
39
- break;
40
- case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
41
- progress.setStatus("Cannot upload Zero Byte files.");
42
- this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
43
- break;
44
- case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
45
- progress.setStatus("Invalid File Type.");
46
- this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
47
- break;
48
- default:
49
- if (file !== null) {
50
- progress.setStatus("Unhandled Error");
51
- }
52
- this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
53
- break;
54
- }
55
- } catch (ex) {
56
- this.debug(ex);
57
- }
58
- }
59
-
60
- function fileDialogComplete(numFilesSelected, numFilesQueued) {
61
- try {
62
- if (numFilesSelected > 0) {
63
- //document.getElementById(this.customSettings.cancelButtonId).disabled = false;
64
- $(this.customSettings.progressTarget).show();
65
- }
66
-
67
- this.startUpload();
68
- } catch (ex) {
69
- this.debug(ex);
70
- }
71
- }
72
-
73
- function uploadProgress(file, bytesLoaded) {
74
- try {
75
- var percent = Math.ceil((bytesLoaded / file.size) * 100);
76
-
77
- var progress = new FileProgress(file, this.customSettings.progressTarget);
78
- progress.setProgress(percent);
79
- if (percent === 100) {
80
- progress.setStatus("Создание thumbnail...");
81
- progress.toggleCancel(false, this);
82
- } else {
83
- progress.setStatus("Загрузка...");
84
- progress.toggleCancel(true, this);
85
- }
86
- } catch (ex) {
87
- this.debug(ex);
88
- }
89
- }
90
-
91
- function uploadSuccess(file, serverData) {
92
- try {
93
- var progress = new FileProgress(file, this.customSettings.progressTarget);
94
- progress.setComplete();
95
- progress.setStatus("Завершено.");
96
- progress.toggleCancel(false);
97
-
98
- progress.setThumbnail(serverData, this.customSettings.collectionTarget);
99
-
100
- } catch (ex) {
101
- this.debug(ex);
102
- }
103
- }
104
-
105
- function uploadComplete(file) {
106
- try {
107
- /* I want the next upload to continue automatically so I'll call startUpload here */
108
- if (this.getStats().files_queued > 0) {
109
- //this.startUpload();
110
- } else {
111
- var progress = new FileProgress(file, this.customSettings.progressTarget);
112
- progress.setComplete();
113
- progress.setStatus("Все картинки успешно обработано.");
114
- progress.toggleCancel(false);
115
- }
116
- } catch (ex) {
117
- this.debug(ex);
118
- }
119
- }
120
-
121
- function uploadError(file, errorCode, message) {
122
- var progress;
123
- try {
124
- switch (errorCode) {
125
- case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
126
- try {
127
- progress = new FileProgress(file, this.customSettings.progressTarget);
128
- progress.setCancelled();
129
- progress.setStatus("Отменено");
130
- progress.toggleCancel(false);
131
- }
132
- catch (ex1) {
133
- this.debug(ex1);
134
- }
135
- break;
136
- case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
137
- try {
138
- progress = new FileProgress(file, this.customSettings.progressTarget);
139
- progress.setCancelled();
140
- progress.setStatus("Остановлено");
141
- progress.toggleCancel(true);
142
- }
143
- catch (ex2) {
144
- this.debug(ex2);
145
- }
146
- case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
147
- break;
148
- default:
149
- alert(message);
150
- break;
151
- }
152
- } catch (ex3) {
153
- this.debug(ex3);
154
- }
155
- }
156
-
157
- // This event comes from the Queue Plugin
158
- function queueComplete(numFilesUploaded) {
159
- var progress_bar = document.getElementById(this.customSettings.progressTarget);
160
- progress_bar.style.display = 'none';
161
-
162
- /*var status = document.getElementById("divStatus");
163
- status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded.";*/
164
- }