2 * FusionForge Documentation Manager
4 * Copyright 2010, Antoine Mercadal - Capgemini
5 * Copyright 2010-2011, Franck Villaume - Capgemini
6 * Copyright 2011, Alain Peyrat
7 * Copyright 2011-2016, Franck Villaume - TrivialDev
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /*! ListFileController
27 * @param groupId the current FusionForge groupID
29 DocManListFileController = function(params)
31 this.lockInterval = [];
32 this.listfileparams = params;
34 if (this.listfileparams.enableResize) {
37 this.initModalEditWindow();
38 this.initModelNotifyWindow();
41 DocManAddItemController = function(params)
43 this.additemparams = params;
47 DocManAddFileController = function(params)
49 this.addfileparams = params;
53 DocManSearchController = function(params)
55 this.searchparams = params;
59 DocManListFileController.prototype =
61 /*! Binds the controls to the actions
63 bindControls: function() {
64 if (typeof(this.listfileparams.buttonAddItem) != 'undefined') {
65 this.listfileparams.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
67 if (typeof(jQuery('#versiontab')) != 'undefined') {
68 jQuery('#versiontab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#versiontab')));
70 if (typeof(jQuery('#reviewtab')) != 'undefined') {
71 jQuery('#reviewtab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#reviewtab')));
73 if (typeof(jQuery('#associationtab')) != 'undefined') {
74 jQuery('#associationtab').click(jQuery.proxy(this, "setRequiredInputs", jQuery('#associationtab')));
78 resizableDiv: function() {
79 var splitterPosition = '30%';
80 var mainwidth = jQuery('#maindiv').innerWidth();
81 if (jQuery.Storage.get('splitterStyle') !== undefined) {
82 var storedSplitterPosition = jQuery.Storage.get('splitterStyle').replace(/px;?/g, '').replace(/left: /g, '');
83 splitterPosition = Math.round(storedSplitterPosition * 100 / mainwidth )+'%';
85 if (this.listfileparams.page == 'trashfile') {
86 (this.listfileparams.divLeft.outerHeight() > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() : mainheight = this.listfileparams.divRight.outerHeight();
89 if (jQuery('#editFile').length >= 1) {
90 fixwidth += jQuery('#editFile').outerHeight() - jQuery('[aria-describedby="editFile"]').outerHeight();
92 if (jQuery('#notifyUsers').length >= 1) {
93 fixwidth += jQuery('#notifyUsers').outerHeight() - jQuery('[aria-describedby="notifyUsers"]').outerHeight();
95 var totalRightHeight = 0;
96 this.listfileparams.divRight.children().each(function() {
97 if (jQuery(this).is(':visible')) {
98 totalRightHeight += jQuery(this).outerHeight();
101 totalRightHeight -= fixwidth;
102 (this.listfileparams.divRight.outerHeight() - fixwidth < 0) ? useRightHeight = this.listfileparams.divRight.outerHeight() : useRightHeight = this.listfileparams.divRight.outerHeight() - fixwidth;
103 (useRightHeight < totalRightHeight) ? useRightHeight = totalRightHeight : useRightHeight ;
104 (this.listfileparams.divLeft.outerHeight() + 30 > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() + 30 : mainheight = useRightHeight;
106 jQuery('#views').height(mainheight)
107 .split({orientation:'vertical', limit:100, position: splitterPosition});
108 jQuery('.vsplitter').mouseup(function(){
109 jQuery.Storage.set('splitterStyle',''+jQuery('.vsplitter').attr('style'));
113 initModalEditWindow: function() {
114 var modalId = this.listfileparams.divEditFile;
115 jQuery(modalId).dialog({
120 Save: jQuery.proxy(function() {
121 jQuery('#editdocdata').submit();
122 var id = jQuery('#docid').attr('value');
123 jQuery.get(this.listfileparams.docManURL+'/', {
124 group_id: this.listfileparams.groupId,
129 childgroup_id: this.listfileparams.childGroupId
131 jQuery.get(this.listfileparams.docManURL+'/', {
132 group_id: this.listfileparams.groupId,
135 itemid: this.listfileparams.docgroupId,
137 childgroup_id: this.listfileparams.childGroupId
139 clearInterval(this.lockInterval[id]);
140 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
141 jQuery(modalId).dialog( "close" );
143 Cancel: jQuery.proxy(function() {
144 var id = jQuery('#docid').attr('value');
145 jQuery.get(this.listfileparams.docManURL+'/', {
146 group_id: this.listfileparams.groupId,
151 childgroup_id: this.listfileparams.childGroupId
153 jQuery.get(this.listfileparams.docManURL+'/', {
154 group_id: this.listfileparams.groupId,
157 itemid: this.listfileparams.docgroupId,
159 childgroup_id: this.listfileparams.childGroupId
161 clearInterval(this.lockInterval[id]);
162 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
163 jQuery(modalId).dialog('close');
167 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
168 var id = jQuery('#docid').attr('value');
169 jQuery.get(this.listfileparams.docManURL+'/', {
170 group_id: this.listfileparams.groupId,
175 childgroup_id: this.listfileparams.childGroupId
177 jQuery.get(this.listfileparams.docManURL+'/', {
178 group_id: this.listfileparams.groupId,
181 itemid: this.listfileparams.docgroupId,
183 childgroup_id: this.listfileparams.childGroupId
185 clearInterval(this.lockInterval[id]);
186 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
190 initModelNotifyWindow: function() {
191 var modalId = this.listfileparams.divNotifyUsers;
192 jQuery(modalId).dialog({
197 Save: { text: this.listfileparams.divNotifySaveButtonTxt,
198 click: jQuery.proxy(function() {
199 jQuery('#notifyusersdoc').submit();
200 var id = jQuery('#docid').attr('value');
201 jQuery.get(this.listfileparams.docManURL+'/', {
202 group_id: this.listfileparams.groupId,
207 childgroup_id: this.listfileparams.childGroupId
209 jQuery.get(this.listfileparams.docManURL+'/', {
210 group_id: this.listfileparams.groupId,
213 itemid: this.listfileparams.docgroupId,
215 childgroup_id: this.listfileparams.childGroupId
217 clearInterval(this.lockInterval[id]);
218 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
219 jQuery(modalId).dialog( "close" );
221 Cancel: jQuery.proxy(function() {
222 var id = jQuery('#docid').attr('value');
223 jQuery.get(this.listfileparams.docManURL+'/', {
224 group_id: this.listfileparams.groupId,
229 childgroup_id: this.listfileparams.childGroupId
231 jQuery.get(this.listfileparams.docManURL+'/', {
232 group_id: this.listfileparams.groupId,
235 itemid: this.listfileparams.docgroupId,
237 childgroup_id: this.listfileparams.childGroupId
239 clearInterval(this.lockInterval[id]);
240 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
241 jQuery(modalId).dialog('close');
245 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
246 var id = jQuery('#docid').attr('value');
247 jQuery.get(this.listfileparams.docManURL+'/', {
248 group_id: this.listfileparams.groupId,
253 childgroup_id: this.listfileparams.childGroupId
255 jQuery.get(this.listfileparams.docManURL+'/', {
256 group_id: this.listfileparams.groupId,
259 itemid: this.listfileparams.docgroupId,
261 childgroup_id: this.listfileparams.childGroupId
263 clearInterval(this.lockInterval[id]);
264 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
268 /*! toggle edit group view div visibility
270 toggleEditDirectoryView: function() {
271 if (!this.listfileparams.divEditDirectory.is(":visible")) {
272 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId, jQuery.proxy(function(data){
273 if (typeof data.html != 'undefined') {
274 jQuery('#maindiv > .feedback').remove();
275 jQuery('#maindiv > .error').remove();
276 jQuery('#maindiv > .warning_msg').remove();
277 jQuery('#maindiv').prepend(data.html);
279 this.listfileparams.divEditDirectory.show();
280 if (typeof(this.listfileparams.divAddItem) != 'undefined') {
281 this.listfileparams.divAddItem.hide();
283 computeHeight = this.listfileparams.divRight.outerHeight() + this.listfileparams.divEditDirectory.outerHeight();
284 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
285 this.listfileparams.divLeft.height(currentLeftHeight + this.listfileparams.divEditDirectory.outerHeight());
286 jQuery.get(this.listfileparams.docManURL+'/', {
287 group_id: this.listfileparams.groupId,
291 itemid: this.listfileparams.docgroupId,
292 childgroup_id: this.listfileparams.childGroupId
294 this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('" + this.listfileparams.docManURL + "/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+"})", this.listfileparams.lockIntervalDelay);
295 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
296 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
297 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
299 jQuery('#views').height(computeHeight);
305 this.listfileparams.divEditDirectory.hide();
306 computeHeight = this.listfileparams.divRight.outerHeight() - this.listfileparams.divEditDirectory.outerHeight();
307 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
308 this.listfileparams.divLeft.height(currentLeftHeight - this.listfileparams.divEditDirectory.outerHeight());
309 jQuery.get(this.listfileparams.docManURL+'/', {
310 group_id: this.listfileparams.groupId,
314 itemid: this.listfileparams.docgroupId,
315 childgroup_id: this.listfileparams.childGroupId
317 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
318 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
319 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
320 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
322 jQuery('#views').height(computeHeight);
329 /*! toggle add item view div visibility
331 toggleAddItemView: function() {
332 if (!this.listfileparams.divAddItem.is(":visible")) {
333 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId, jQuery.proxy(function(data){
334 if (typeof data.html != 'undefined') {
335 jQuery('#maindiv > .feedback').remove();
336 jQuery('#maindiv > .error').remove();
337 jQuery('#maindiv > .warning_msg').remove();
338 jQuery('#maindiv').prepend(data.html);
340 jQuery.get(this.listfileparams.docManURL+'/', {
341 group_id: this.listfileparams.groupId,
345 itemid: this.listfileparams.docgroupId,
346 childgroup_id: this.listfileparams.childGroupId
348 this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('"+this.listfileparams.docManURL+"/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+"})", this.listfileparams.lockIntervalDelay);
349 this.listfileparams.divAddItem.show();
350 this.listfileparams.divEditDirectory.hide();
351 computeHeight = this.listfileparams.divRight.outerHeight() + jQuery(this.listfileparams.divAddItem).outerHeight();
352 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
353 this.listfileparams.divLeft.height(currentLeftHeight + jQuery(this.listfileparams.divAddItem).outerHeight());
354 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
355 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
356 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
358 jQuery('#views').height(computeHeight);
364 jQuery.get(this.listfileparams.docManURL+'/', {
365 group_id: this.listfileparams.groupId,
369 itemid: this.listfileparams.docgroupId,
370 childgroup_id: this.listfileparams.childGroupId
372 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
373 this.listfileparams.divAddItem.hide();
374 computeHeight = this.listfileparams.divRight.outerHeight() - jQuery(this.listfileparams.divAddItem).outerHeight();
375 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
376 this.listfileparams.divLeft.height(currentLeftHeight - jQuery(this.listfileparams.divAddItem).outerHeight());
377 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
378 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
379 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
381 jQuery('#views').height(computeHeight);
388 /*! toggle add file edit view div visibility and play with lock
390 * @param params array
392 toggleEditFileView: function(params) {
393 this.docparams = params;
394 this.listfileparams.tableAddVersion.hide();
395 jQuery('#doc_group').empty();
396 for (var i = 0; i < this.docparams.docgroupDict.length; i++) {
397 jQuery('#doc_group').append(jQuery('<option>').text(this.docparams.docgroupDict[i][1]).attr('value', this.docparams.docgroupDict[i][0]));
399 jQuery('#doc_group option[value='+this.docparams.docgroupId+']').attr('selected', 'selected');
400 jQuery('#stateid').empty();
401 jQuery.each(this.docparams.statusDict, function(key, value) {
402 jQuery('#stateid').append(jQuery('<option>').text(key).attr('value',value));
404 jQuery('#stateid option[value='+this.docparams.statusId+']').attr('selected', 'selected');
405 jQuery('#docid').val(this.docparams.id);
406 var docid_groupid = this.listfileparams.groupId;
407 if (this.listfileparams.childGroupId != 0) {
408 docid_groupid = this.listfileparams.childGroupId;
410 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocversions&docid='+ this.docparams.id, jQuery.proxy(function(data){
411 if (typeof data.html != 'undefined') {
412 jQuery('#editFile > .feedback').remove();
413 jQuery('#editFile > .error').remove();
414 jQuery('#editFile > .warning_msg').remove();
415 jQuery('#editFile > .information').remove();
416 jQuery('#editFile').prepend(data.html);
418 jQuery('#sortable_doc_version_table > tbody').children().remove();
419 jQuery('#sortable_doc_version_table > tbody').css('max-height', '400px').css('overflow-y', 'auto').css('display', 'block');
420 jQuery('#sortable_doc_version_table > thead > tr').css('display', 'block');
421 eachdocparams = this.docparams;
422 jQuery.each(data, function (i, val) {
423 //_('ID (x)'), _('Filename'), _('Title'), _('Description'), _('Comment'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
424 currenttdcontent = '';
425 if (val.current_version == 1) {
426 currenttdcontent += ' (x)';
428 if (eachdocparams.statusId != 2) {
429 filenametdcontent = jQuery('<a>'+val.filename+'</a>');
430 if (val.filetype == 'URL') {
432 filenametdcontent.attr('href', val.filename);
434 filenametdcontent.attr('href', eachdocparams.docManURL+'/view.php/'+eachdocparams.groupId+'/versions/'+eachdocparams.id+'/'+val.version.substring(1));
437 filenametdcontent = jQuery('<span>'+val.filename+'</span>');
439 versionactiontdcontent = '';
440 versionActionsArrayLength = val.versionactions.length;
441 for (var i = 0; i < versionActionsArrayLength; i++) {
442 versionactiontdcontent += val.versionactions[i];
444 // please sync with the editfile.php widths if you change it here.
445 var htmlString = '<tr id="docversion'+val.version.substr(1)+'" ><td style="width: 60px">'+val.version.substr(1)+currenttdcontent+'</td><td style="width: 150px">'+filenametdcontent[0].outerHTML+'</td><td style="width: 150px">'+val.title+'</td><td style="width: 150px">'+val.description+'</td><td style="width: 110px">'+val.vcomment+'</td><td style="width: 100px">'+val.created_by_username+'</td><td style="width: 100px">'+val.lastdate+'</td><td style="width: 50px">'+val.filesize_readable+'</td><td style="width: 50px">'+versionactiontdcontent+'</td></tr>'
446 jQuery('#sortable_doc_version_table > tbody:last-child').append(htmlString);
451 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getassociations&docid='+ this.docparams.id, jQuery.proxy(function(data){
452 if (typeof data.html != 'undefined') {
453 jQuery('#tabbereditfile-association > .feedback').remove();
454 jQuery('#tabbereditfile-association > .error').remove();
455 jQuery('#tabbereditfile-association > .warning_msg').remove();
456 jQuery('#tabbereditfile-association > .information').remove();
457 jQuery('#tabbereditfile-association > table').remove();
458 jQuery('#tabbereditfile-association > span').remove();
459 jQuery('#tabbereditfile-association > p').remove();
460 jQuery('#tabbereditfile-association').prepend(data.html);
462 if (typeof data.htmltab != 'undefined') {
463 jQuery('#associationtab').text(data.htmltab);
467 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocreviews&docid='+ this.docparams.id, jQuery.proxy(function(data){
468 if (typeof data.html != 'undefined') {
469 jQuery('#tabbereditfile-review > .feedback').remove();
470 jQuery('#tabbereditfile-review > .error').remove();
471 jQuery('#tabbereditfile-review > .warning_msg').remove();
472 jQuery('#tabbereditfile-review > .information').remove();
473 jQuery('#tabbereditfile-review > table').remove();
474 jQuery('#tabbereditfile-review > span').remove();
475 jQuery('#tabbereditfile-review > p').remove();
476 jQuery('#editfile-createreview').remove();
477 jQuery('#doc_review_addbutton').remove();
478 jQuery('#tabbereditfile-review').prepend(data.html);
479 jQuery('#doc_review_addbutton').button();
481 if (typeof data.htmltab != 'undefined') {
482 jQuery('#reviewtab').text(data.htmltab);
484 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
485 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
488 jQuery('#editdocdata').attr('action', this.docparams.action);
490 jQuery.get(this.docparams.docManURL+'/', {
491 group_id: this.docparams.groupId,
495 itemid: this.docparams.docgroupId,
496 childgroup_id: this.docparams.childGroupId
498 this.lockInterval[this.docparams.id] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type:'file', itemid:"+this.docparams.id+", childgroup_id:"+this.docparams.childGroupId+"})", this.docparams.lockIntervalDelay);
499 this.lockInterval[this.docparams.docgroupId] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type: 'dir', itemid:"+this.docparams.docgroupId+", childgroup_id:"+this.docparams.childGroupId+"})", this.docparams.lockIntervalDelay);
500 jQuery('#tabbereditfile').tabs("option", "active", 0);
501 this.setRequiredInputs(jQuery('#versiontab'));
502 jQuery(this.listfileparams.divEditFile).dialog('option', 'title', '[D'+this.docparams.id+'] '+this.listfileparams.divEditTitle).dialog('open');
506 toggleAddVersionView: function() {
507 jQuery('#title').val('');
508 jQuery('#description').val('');
509 jQuery(':file').val('');
510 jQuery('#edit_version').val('');
511 jQuery('#defaulteditzone').text();
512 jQuery('#current_version').prop('checked', false);
513 jQuery('#current_version').attr('onclick', 'return true');
514 if (!this.listfileparams.tableAddVersion.is(':visible')) {
515 jQuery('#new_version').val(1);
516 this.listfileparams.tableAddVersion.show();
518 this.listfileparams.tableAddVersion.hide();
519 jQuery('#new_version').val(0);
523 toggleAddReviewView: function() {
524 jQuery('#review-title').val('');
525 jQuery('#review-description').val('');
526 jQuery('#datepicker_end_review_date').val('');
527 jQuery('#review-serialid').val();
528 jQuery('[class^=gentle]').remove();
529 jQuery('#review-select-mandatory-users').val('');
530 jQuery('#review-select-optional-users').val('');
531 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
532 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
533 jQuery('#editfile-userstatusreview').empty();
534 jQuery('#editfile-completedreview').empty();
535 if (jQuery('#editfile-createreview').is(':visible')) {
536 jQuery('#editfile-createreview').hide();
537 jQuery('#new_review').val(0);
539 jQuery('#new_review').val(1);
540 jQuery('#editfile-createreview').show();
544 toggleEditReviewView: function(params) {
545 this.review = params;
546 if (jQuery('#editfile-createreview').is(':visible')) {
547 jQuery('#editfile-createreview').hide();
548 jQuery('#new_review').val(0);
549 jQuery('#review_id').val(0);
550 jQuery('#review_complete').val(0);
551 jQuery('#editfile-userstatusreview').empty();
552 jQuery('#editfile-completedreview').empty();
554 jQuery('#review_id').val(this.review.review);
555 jQuery('#review-title').val(this.review.title);
556 jQuery('#review-description').val(this.review.description);
557 jQuery('#datepicker_end_review_date').val(this.review.endreviewdate);
558 jQuery('#review-serialid').val(this.review.serialid);
559 if (this.review.complete) {
560 jQuery('#tr-mandatory-reviewers').hide();
561 jQuery('#tr-optional-reviewers').hide();
562 jQuery('#review_complete').val(1);
563 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=getdocreviewcompleteform&docid='+this.docparams.id+'&revid='+this.review.review , jQuery.proxy(function(data){
564 if (typeof data.html != 'undefined') {
565 jQuery('#editfile-completedreview').prepend(data.html);
569 jQuery('#tr-mandatory-reviewers').show();
570 jQuery('#tr-optional-reviewers').show();
571 jQuery('[class^=gentle]').remove();
572 jQuery('#review-select-mandatory-users').val(this.review.mandatoryusers);
573 jQuery('#review-select-optional-users').val(this.review.optionalusers);
574 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
575 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
577 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=getdocreviewuserstatus&docid='+this.docparams.id+'&revid='+this.review.review , jQuery.proxy(function(data){
578 if (typeof data.html != 'undefined') {
579 jQuery('#editfile-userstatusreview').prepend(data.html);
582 jQuery('#new_review').val(0);
583 jQuery('#editfile-createreview').show();
587 toggleEditVersionView: function(params) {
588 this.version = params;
589 jQuery('#new_version').val(0);
590 if (this.version.isHtml) {
591 jQuery('#defaulteditfiletype').val('text/html');
593 if (this.version.isText && !this.version.isHtml) {
594 jQuery('#defaulteditfiletype').val('text/plain');
596 if (this.version.isText) {
597 jQuery.getJSON(this.listfileparams.docManURL+'/?group_id='+this.version.groupId+'&action=getfile&type=file&itemid='+this.version.id+'&version='+this.version.version, jQuery.proxy(function(data){
599 jQuery('#defaulteditzone').text(data.body);
604 if (!this.listfileparams.tableAddVersion.is(':visible')) {
605 if (this.version.isURL) {
606 jQuery('#uploadnewroweditfile').hide();
607 jQuery('#fileurlroweditfile').show();
608 jQuery('#fileurlroweditfile').find('input').attr('required', 'required').prop('required', true);
609 jQuery('#fileurlroweditfile').find('input').val(this.version.filename);
610 jQuery('#editonlineroweditfile').hide();
611 jQuery('#editor').attr('disabled', true);
612 jQuery('#editButtonUrl').prop('checked', true);
613 } else if (this.listfileparams.useCreateOnline && this.version.isText){
614 jQuery('#fileurlroweditfile').hide();
615 jQuery('#uploadnewroweditfile').hide();
616 jQuery('#editonlineroweditfile').show();
617 jQuery('#editor').removeAttr('disabled');
618 jQuery('#editButtonEditor').prop('checked', true);
620 jQuery('#onlineroweditfile').hide();
621 jQuery('#editor').attr('disabled', true);
622 jQuery('#fileurlroweditfile').hide();
623 jQuery('#uploadnewroweditfile').show();
624 jQuery('#editButtonFile').prop('checked', true);
626 jQuery('#title').val(this.version.title);
627 jQuery('#description').val(this.version.description);
628 jQuery('#vcomment').val(this.version.vcomment);
629 jQuery('#edit_version').val(this.version.version);
630 if (this.version.current_version == 1) {
631 jQuery('#current_version').attr('checked', 'checked').prop('checked', true);
632 jQuery('#current_version').attr('onclick', 'return false');
634 this.listfileparams.tableAddVersion.show();
636 this.listfileparams.tableAddVersion.hide();
637 jQuery('#title').val('');
638 jQuery('#description').val('');
639 jQuery('#vcomment').val('');
640 jQuery(':file').val('');
641 jQuery('#edit_version').val('');
642 jQuery('#current_version').removeAttr('checked');
643 jQuery('#current_version').attr('onclick', 'return true');
644 jQuery('#fileurlroweditfile').find('input').val('');
645 jQuery('#fileurlroweditfile').find('input').removeAttr('required');
646 jQuery('#fileurlroweditfile').hide();
647 jQuery('#uploadnewroweditfile').hide();
648 jQuery('#editonlineroweditfile').hide();
649 jQuery('#defaulteditzone').text('');
653 deleteVersion: function(params) {
654 this.delversion = params;
656 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.delversion.groupId + '&action=deleteversion&docid='+this.delversion.docid+'&version='+this.delversion.version , jQuery.proxy(function(data){
657 if (typeof data.html != 'undefined') {
658 jQuery('#editFile > .feedback').remove();
659 jQuery('#editFile > .error').remove();
660 jQuery('#editFile > .warning_msg').remove();
661 jQuery('#editFile').prepend(data.html);
663 if (typeof data.status != 'undefined') {
664 if (data.status == 1) {
665 jQuery('#docversion'+this.version).remove();
666 //adjust review tab & version tab number?
667 if (jQuery('#docversionreview'+this.version) != 'undefined') {
668 jQuery('#docversionreview'+this.version).parent.remove();
670 if (jQuery('#sortable_doc_version_table tr').length <= 2) {
671 jQuery('#version_action_delete').remove();
675 }, this.delversion));
678 deleteReview: function(params) {
679 this.delreview = params;
680 jQuery('#editfile-createreview').hide();
681 jQuery('#new_review').val(0);
682 jQuery('#review_id').val(0);
683 jQuery('#review_complete').val(0);
684 jQuery('#editfile-userstatusreview').empty();
685 jQuery('#editfile-completedreview').empty();
686 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=deletereview&docid='+this.docparams.id+'&review='+this.delreview.review , jQuery.proxy(function(data){
687 if (typeof data.html != 'undefined') {
688 jQuery('#editFile > .feedback').remove();
689 jQuery('#editFile > .error').remove();
690 jQuery('#editFile > .warning_msg').remove();
691 jQuery('#editFile').prepend(data.html);
693 if (typeof data.status != 'undefined') {
694 if (data.status == 1) {
695 jQuery('#docreview'+this.review).remove();
696 //adjust review tab number?
702 reminderReview: function(params) {
703 this.reminderreview = params;
704 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=reminderreview&docid='+this.docparams.id+'&review='+this.reminderreview.review , jQuery.proxy(function(data){
705 if (typeof data.html != 'undefined') {
706 jQuery('#editFile > .feedback').remove();
707 jQuery('#editFile > .error').remove();
708 jQuery('#editFile > .warning_msg').remove();
709 jQuery('#editFile').prepend(data.html);
711 }, this.reminderreview));
714 toggleMoveFileView: function() {
715 if (!this.listfileparams.divMoveFile.is(':visible')) {
716 this.listfileparams.divMoveFile.show();
717 jQuery('#movefileinput').val(function() {
718 var CheckedBoxes = new Array();
719 for (var h = 0; h < jQuery('input:checked').length; h++) {
720 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocidactive')) {
721 CheckedBoxes.push(jQuery('input:checked')[h].value);
727 this.listfileparams.divMoveFile.hide();
731 toggleNotifyUserView: function(params) {
732 this.notifyparams = params;
733 jQuery('#notifytitle').text(this.notifyparams.title);
734 jQuery('#notifydescription').html(this.notifyparams.description);
735 jQuery('#notifydocid').val(this.notifyparams.id);
736 jQuery('#notifyfilelink').text(this.notifyparams.filename);
737 if (this.notifyparams.statusId != 2) {
738 if (this.notifyparams.isURL) {
739 jQuery('#notifyfilelink').attr('href', this.notifyparams.filename);
741 jQuery('#notifyfilelink').attr('href', this.notifyparams.docManURL+'/view.php/'+this.notifyparams.groupId+'/'+this.notifyparams.id);
745 jQuery('#notifyusersdoc').attr('action', this.notifyparams.action);
746 jQuery.get(this.notifyparams.docManURL+'/', {
747 group_id: this.notifyparams.groupId,
751 itemid: this.notifyparams.docgroupId,
752 childgroup_id: this.notifyparams.childGroupId
754 this.lockInterval[this.notifyparams.id] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'file',itemid:"+this.notifyparams.id+",childgroup_id:"+this.notifyparams.childGroupId+"})", this.notifyparams.lockIntervalDelay);
755 this.lockInterval[this.notifyparams.docgroupId] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.notifyparams.docgroupId+",childgroup_id:"+this.notifyparams.childGroupId+"})", this.notifyparams.lockIntervalDelay);
756 jQuery('#notify-userids').gentleSelect({columns: 2, itemWidth: 120});
757 jQuery(this.listfileparams.divNotifyUsers).dialog('option', 'title', '[D'+this.notifyparams.id+'] '+this.listfileparams.divNotifyTitle).dialog('open');
763 /*! build list of id, comma separated
765 buildUrlByCheckbox: function(id) {
766 var CheckedBoxes = new Array();
767 for (var h = 0; h < jQuery('input:checked').length; h++) {
768 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocid'+id)) {
769 CheckedBoxes.push(jQuery('input:checked')[h].value);
775 checkAll: function(id, type) {
776 if (jQuery('#checkall'+type).is(':checked')) {
777 jQuery('.'+id).each(function() {
778 jQuery(this).prop('checked', true);
780 jQuery('#massaction'+type).show();
782 jQuery('.'+id).each(function() {
783 jQuery(this).prop('checked', false);
785 jQuery('#massaction'+type).hide();
789 checkgeneral: function(id) {
790 if (jQuery(this).attr('checked', false)) {
791 jQuery('#checkall'+id).prop('checked', false);
792 jQuery('#massaction'+id).hide();
793 jQuery('#movefile').hide();
795 for (var h = 0; h < jQuery('input:checked').length; h++) {
796 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocid'+id)) {
797 jQuery('#massaction'+id).show();
803 setRequiredInputs: function(id) {
804 if (id.attr('id') == 'reviewtab') {
805 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
806 jQuery('#tabbereditfile-association').prop('disabled', true);
807 jQuery('#tabbereditfile-review :input').removeAttr('disabled');
808 jQuery('#subaction').val('review');
809 } else if (id.attr('id') == 'associationtab') {
810 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
811 jQuery('#tabbereditfile-association').removeAttr('disabled');
812 jQuery('#tabbereditfile-review :input').prop('disabled', true);
813 jQuery('#subaction').val('association');
814 } else if (id.attr('id') == 'versiontab') {
815 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').removeAttr('disabled');
816 jQuery('#tabbereditfile-association').prop('disabled', true);
817 jQuery('#tabbereditfile-review :input').prop('disabled', true);
818 jQuery('#subaction').val('version');
823 DocManAddItemController.prototype =
825 /*! Binds the controls to the actions
827 bindControls: function() {
828 this.additemparams.submitZip.click(jQuery.proxy(this, "submitFormZip"));
831 submitFormZip: function() {
832 this.additemparams.injectZip.submit();
833 this.additemparams.submitZip.attr('disabled', true);
837 DocManAddFileController.prototype =
839 /*! Binds the controls to the actions
841 bindControls: function() {
842 this.addfileparams.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
843 this.addfileparams.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
844 if (typeof(this.addfileparams.buttonManualUpload) != 'undefined') {
845 this.addfileparams.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
847 if (typeof(this.addfileparams.buttonEditor) != 'undefined') {
848 this.addfileparams.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
852 toggleFileRowView: function() {
853 this.addfileparams.fileRow.show();
854 this.addfileparams.fileRow.find('input').attr("required", "required");
855 this.addfileparams.urlRow.hide();
856 this.addfileparams.urlRow.find('input').removeAttr("required");
857 this.addfileparams.pathRow.hide();
858 this.addfileparams.pathRow.find('input').removeAttr("required");
859 this.addfileparams.editRow.hide();
860 this.addfileparams.editNameRow.hide();
863 toggleUrlRowView: function() {
864 this.addfileparams.fileRow.hide();
865 this.addfileparams.fileRow.find('input').removeAttr("required");
866 this.addfileparams.urlRow.show();
867 this.addfileparams.urlRow.find('input').attr("required", "required");
868 this.addfileparams.pathRow.hide();
869 this.addfileparams.pathRow.find('input').removeAttr("required");
870 this.addfileparams.editRow.hide();
871 this.addfileparams.editNameRow.hide();
874 toggleManualUploadView: function() {
875 this.addfileparams.fileRow.hide();
876 this.addfileparams.fileRow.find('input').removeAttr("required");
877 this.addfileparams.urlRow.hide();
878 this.addfileparams.urlRow.find('input').removeAttr("required");
879 this.addfileparams.pathRow.show();
880 this.addfileparams.pathRow.find('input').attr("required", "required");
881 this.addfileparams.editRow.hide();
882 this.addfileparams.editNameRow.hide();
885 toggleEditorView: function() {
886 this.addfileparams.fileRow.hide();
887 this.addfileparams.fileRow.find('input').removeAttr("required");
888 this.addfileparams.urlRow.hide();
889 this.addfileparams.urlRow.find('input').removeAttr("required");
890 this.addfileparams.pathRow.hide();
891 this.addfileparams.pathRow.find('input').removeAttr("required");
892 this.addfileparams.editRow.show();
893 this.addfileparams.editNameRow.show();
897 DocManSearchController.prototype =
899 /*! Binds the controls to the actions
901 bindControls: function() {
902 this.searchparams.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
903 this.searchparams.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
906 setStartDate: function() {
907 if (this.searchparams.buttonStartDate.is(':checked')) {
908 this.searchparams.datePickerStartDate.removeAttr('disabled');
909 this.searchparams.datePickerStartDate.attr('required', 'required');
911 this.searchparams.datePickerStartDate.attr('disabled', 'disabled');
912 this.searchparams.datePickerStartDate.removeAttr('required');
916 setEndDate: function() {
917 if (this.searchparams.buttonEndDate.is(':checked')) {
918 this.searchparams.datePickerEndDate.removeAttr('disabled');
919 this.searchparams.datePickerEndDate.attr('required', 'required');
921 this.searchparams.datePickerEndDate.attr('disabled', 'disabled');
922 this.searchparams.datePickerEndDate.removeAttr('required');