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-2017, 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 this.listfileparams.nocache = new Date().getTime();
116 jQuery(modalId).dialog({
121 Save: jQuery.proxy(function() {
122 jQuery('#editdocdata').submit();
123 var id = jQuery('#docid').attr('value');
124 jQuery.get(this.listfileparams.docManURL+'/', {
125 group_id: this.listfileparams.groupId,
130 childgroup_id: this.listfileparams.childGroupId,
131 rqd: this.listfileparams.nocache
133 jQuery.get(this.listfileparams.docManURL+'/', {
134 group_id: this.listfileparams.groupId,
137 itemid: this.listfileparams.docgroupId,
139 childgroup_id: this.listfileparams.childGroupId,
140 rqd: this.listfileparams.nocache
142 clearInterval(this.lockInterval[id]);
143 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
144 jQuery(modalId).dialog( "close" );
146 Cancel: jQuery.proxy(function() {
147 var id = jQuery('#docid').attr('value');
148 jQuery.get(this.listfileparams.docManURL+'/', {
149 group_id: this.listfileparams.groupId,
154 childgroup_id: this.listfileparams.childGroupId,
155 rqd: this.listfileparams.nocache
157 jQuery.get(this.listfileparams.docManURL+'/', {
158 group_id: this.listfileparams.groupId,
161 itemid: this.listfileparams.docgroupId,
163 childgroup_id: this.listfileparams.childGroupId,
164 rqd: this.listfileparams.nocache
166 clearInterval(this.lockInterval[id]);
167 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
168 jQuery(modalId).dialog('close');
172 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
173 var id = jQuery('#docid').attr('value');
174 jQuery.get(this.listfileparams.docManURL+'/', {
175 group_id: this.listfileparams.groupId,
180 childgroup_id: this.listfileparams.childGroupId,
181 rqd: this.listfileparams.nocache
183 jQuery.get(this.listfileparams.docManURL+'/', {
184 group_id: this.listfileparams.groupId,
187 itemid: this.listfileparams.docgroupId,
189 childgroup_id: this.listfileparams.childGroupId,
190 rqd: this.listfileparams.nocache
192 clearInterval(this.lockInterval[id]);
193 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
194 jQuery('#editfile-userstatusreview').remove();
195 jQuery('#editfile-completedreview').remove();
196 jQuery('#editfile-datepickerreview-script').remove();
197 jQuery('#editfile-commentreview').remove();
201 initModelNotifyWindow: function() {
202 var modalId = this.listfileparams.divNotifyUsers;
203 this.listfileparams.nocache = new Date().getTime();
204 jQuery(modalId).dialog({
209 Save: { text: this.listfileparams.divNotifySaveButtonTxt,
210 click: jQuery.proxy(function() {
211 jQuery('#notifyusersdoc').submit();
212 var id = jQuery('#docid').attr('value');
213 jQuery.get(this.listfileparams.docManURL+'/', {
214 group_id: this.listfileparams.groupId,
219 childgroup_id: this.listfileparams.childGroupId,
220 rqd: this.listfileparams.nocache
222 jQuery.get(this.listfileparams.docManURL+'/', {
223 group_id: this.listfileparams.groupId,
226 itemid: this.listfileparams.docgroupId,
228 childgroup_id: this.listfileparams.childGroupId,
229 rqd: this.listfileparams.nocache
231 clearInterval(this.lockInterval[id]);
232 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
233 jQuery(modalId).dialog( "close" );
235 Cancel: jQuery.proxy(function() {
236 var id = jQuery('#docid').attr('value');
237 jQuery.get(this.listfileparams.docManURL+'/', {
238 group_id: this.listfileparams.groupId,
243 childgroup_id: this.listfileparams.childGroupId,
244 rqd: this.listfileparams.nocache
246 jQuery.get(this.listfileparams.docManURL+'/', {
247 group_id: this.listfileparams.groupId,
250 itemid: this.listfileparams.docgroupId,
252 childgroup_id: this.listfileparams.childGroupId,
253 rqd: this.listfileparams.nocache
255 clearInterval(this.lockInterval[id]);
256 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
257 jQuery(modalId).dialog('close');
261 jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
262 var id = jQuery('#docid').attr('value');
263 jQuery.get(this.listfileparams.docManURL+'/', {
264 group_id: this.listfileparams.groupId,
269 childgroup_id: this.listfileparams.childGroupId,
270 rqd: this.listfileparams.nocache
272 jQuery.get(this.listfileparams.docManURL+'/', {
273 group_id: this.listfileparams.groupId,
276 itemid: this.listfileparams.docgroupId,
278 childgroup_id: this.listfileparams.childGroupId,
279 rqd: this.listfileparams.nocache
281 clearInterval(this.lockInterval[id]);
282 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
286 /*! toggle edit group view div visibility
288 toggleEditDirectoryView: function() {
289 this.listfileparams.nocache = new Date().getTime();
290 if (!this.listfileparams.divEditDirectory.is(":visible")) {
291 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId+'&childgroup_id='+this.listfileparams.childGroupId+'&rqd='+this.listfileparams.nocache, jQuery.proxy(function(data){
292 if (typeof data.html != 'undefined') {
293 jQuery('#maindiv > .feedback').remove();
294 jQuery('#maindiv > .error').remove();
295 jQuery('#maindiv > .warning_msg').remove();
296 jQuery('#maindiv').prepend(data.html);
298 this.listfileparams.divEditDirectory.show();
299 if (typeof(this.listfileparams.divAddItem) != 'undefined') {
300 this.listfileparams.divAddItem.hide();
302 computeHeight = this.listfileparams.divRight.outerHeight() + this.listfileparams.divEditDirectory.outerHeight();
303 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
304 this.listfileparams.divLeft.height(currentLeftHeight + this.listfileparams.divEditDirectory.outerHeight());
305 jQuery.get(this.listfileparams.docManURL+'/', {
306 group_id: this.listfileparams.groupId,
310 itemid: this.listfileparams.docgroupId,
311 childgroup_id: this.listfileparams.childGroupId,
312 rqd: this.listfileparams.nocache
314 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+", rqd:"+this.listfileparams.nocache+"})", this.listfileparams.lockIntervalDelay);
315 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
316 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
317 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
319 jQuery('#views').height(computeHeight);
323 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
324 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
325 jQuery('#maindiv').prepend(error_msg);
328 this.listfileparams.divEditDirectory.hide();
329 computeHeight = this.listfileparams.divRight.outerHeight() - this.listfileparams.divEditDirectory.outerHeight();
330 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
331 this.listfileparams.divLeft.height(currentLeftHeight - this.listfileparams.divEditDirectory.outerHeight());
332 jQuery.get(this.listfileparams.docManURL+'/', {
333 group_id: this.listfileparams.groupId,
337 itemid: this.listfileparams.docgroupId,
338 childgroup_id: this.listfileparams.childGroupId,
339 rqd: this.listfileparams.nocache
341 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
342 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
343 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
344 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
346 jQuery('#views').height(computeHeight);
353 /*! toggle add item view div visibility
355 toggleAddItemView: function() {
356 this.listfileparams.nocache = new Date().getTime();
357 if (!this.listfileparams.divAddItem.is(":visible")) {
358 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId+'&childgroup_id='+this.listfileparams.childGroupId+'&rqd='+this.listfileparams.nocache, jQuery.proxy(function(data){
359 if (typeof data.html != 'undefined') {
360 jQuery('#maindiv > .feedback').remove();
361 jQuery('#maindiv > .error').remove();
362 jQuery('#maindiv > .warning_msg').remove();
363 jQuery('#maindiv').prepend(data.html);
365 jQuery.get(this.listfileparams.docManURL+'/', {
366 group_id: this.listfileparams.groupId,
370 itemid: this.listfileparams.docgroupId,
371 childgroup_id: this.listfileparams.childGroupId
373 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+", rqd:"+this.listfileparams.nocache+"})", this.listfileparams.lockIntervalDelay);
374 this.listfileparams.divAddItem.show();
375 this.listfileparams.divEditDirectory.hide();
376 computeHeight = this.listfileparams.divRight.outerHeight() + jQuery(this.listfileparams.divAddItem).outerHeight();
377 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
378 this.listfileparams.divLeft.height(currentLeftHeight + jQuery(this.listfileparams.divAddItem).outerHeight());
379 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
380 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
381 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
383 jQuery('#views').height(computeHeight);
387 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
388 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
389 jQuery('#maindiv').prepend(error_msg);
392 jQuery.get(this.listfileparams.docManURL+'/', {
393 group_id: this.listfileparams.groupId,
397 itemid: this.listfileparams.docgroupId,
398 childgroup_id: this.listfileparams.childGroupId,
399 rqd: this.listfileparams.nocache
401 clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
402 this.listfileparams.divAddItem.hide();
403 computeHeight = this.listfileparams.divRight.outerHeight() - jQuery(this.listfileparams.divAddItem).outerHeight();
404 currentLeftHeight = this.listfileparams.divLeft.outerHeight();
405 this.listfileparams.divLeft.height(currentLeftHeight - jQuery(this.listfileparams.divAddItem).outerHeight());
406 if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
407 if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
408 jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
410 jQuery('#views').height(computeHeight);
417 /*! toggle add file edit view div visibility and play with lock
419 * @param params array
421 toggleEditFileView: function(params) {
422 this.docparams = params;
423 this.listfileparams.tableAddVersion.hide();
424 jQuery('#doc_group').empty();
425 jQuery('#editfile-userstatusreview').empty();
426 jQuery('#editfile-completedreview').empty();
427 jQuery('#editfile-commentreview').empty();
428 for (var i = 0; i < this.docparams.docgroupDict.length; i++) {
429 jQuery('#doc_group').append(jQuery('<option>').text(this.docparams.docgroupDict[i][1]).attr('value', this.docparams.docgroupDict[i][0]));
431 jQuery('#doc_group option[value='+this.docparams.docgroupId+']').attr('selected', 'selected');
432 jQuery('#stateid').empty();
433 jQuery.each(this.docparams.statusDict, function(key, value) {
434 jQuery('#stateid').append(jQuery('<option>').text(key).attr('value',value));
436 jQuery('#stateid option[value='+this.docparams.statusId+']').attr('selected', 'selected');
437 jQuery('#docid').val(this.docparams.id);
438 var docid_groupid = this.listfileparams.groupId;
439 if (this.listfileparams.childGroupId != 0) {
440 docid_groupid = this.listfileparams.childGroupId;
442 var nocache = new Date().getTime();
443 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocversions&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
444 if (typeof data.html != 'undefined') {
445 jQuery('#editFile > .feedback').remove();
446 jQuery('#editFile > .error').remove();
447 jQuery('#editFile > .warning_msg').remove();
448 jQuery('#editFile > .information').remove();
449 jQuery('#editFile').prepend(data.html);
451 jQuery('#sortable_doc_version_table > tbody').children().remove();
452 jQuery('#sortable_doc_version_table > tbody').css('max-height', '400px').css('overflow-y', 'auto').css('display', 'block');
453 jQuery('#sortable_doc_version_table > thead > tr').css('display', 'block');
454 eachdocparams = this.docparams;
455 jQuery.each(data, function (i, val) {
456 //_('ID (x)'), _('Filename'), _('Title'), _('Description'), _('Comment'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
457 currenttdcontent = '';
458 if (val.current_version == 1) {
459 currenttdcontent += ' (x)';
461 if (eachdocparams.statusId != 2) {
462 filenametdcontent = jQuery('<a>'+val.filename+'</a>');
463 if (val.filetype == 'URL') {
465 filenametdcontent.attr('href', val.filename);
467 filenametdcontent.attr('href', eachdocparams.docManURL+'/view.php/'+eachdocparams.groupId+'/versions/'+eachdocparams.id+'/'+val.version.substring(1));
470 filenametdcontent = jQuery('<span>'+val.filename+'</span>');
472 versionactiontdcontent = '';
473 versionActionsArrayLength = val.versionactions.length;
474 for (var i = 0; i < versionActionsArrayLength; i++) {
475 versionactiontdcontent += val.versionactions[i];
477 // please sync with the editfile.php widths if you change it here.
478 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.new_description.replace(/\\n/g, '<br />')+'</td><td style="width: 110px">'+val.vcomment.replace(/\\n/g, '<br />')+'</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>'
479 jQuery('#sortable_doc_version_table > tbody:last-child').append(htmlString);
482 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
483 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
484 jQuery('#editFile').prepend(error_msg);
487 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getassociations&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
488 if (typeof data.html != 'undefined') {
489 jQuery('#tabbereditfile-association > .feedback').remove();
490 jQuery('#tabbereditfile-association > .error').remove();
491 jQuery('#tabbereditfile-association > .warning_msg').remove();
492 jQuery('#tabbereditfile-association > .information').remove();
493 jQuery('#tabbereditfile-association > table').remove();
494 jQuery('#tabbereditfile-association > span').remove();
495 jQuery('#tabbereditfile-association > p').remove();
496 jQuery('#tabbereditfile-association').prepend(data.html);
498 if (typeof data.htmltab != 'undefined') {
499 jQuery('#associationtab').text(data.htmltab);
501 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
502 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
503 jQuery('#tabbereditfile-association').prepend(error_msg);
506 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocreviews&docid='+ this.docparams.id+'&rqd='+nocache, jQuery.proxy(function(data){
507 if (typeof data.html != 'undefined') {
508 jQuery('#tabbereditfile-review > .feedback').remove();
509 jQuery('#tabbereditfile-review > .error').remove();
510 jQuery('#tabbereditfile-review > .warning_msg').remove();
511 jQuery('#tabbereditfile-review > .information').remove();
512 jQuery('#tabbereditfile-review > table').remove();
513 jQuery('#tabbereditfile-review > span').remove();
514 jQuery('#tabbereditfile-review > p').remove();
515 jQuery('#editfile-createreview').remove();
516 jQuery('#doc_review_addbutton').remove();
517 jQuery('#tabbereditfile-review').prepend(data.html);
518 jQuery('#doc_review_addbutton').button();
520 if (typeof data.htmltab != 'undefined') {
521 jQuery('#reviewtab').text(data.htmltab);
523 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
524 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
525 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
526 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
527 jQuery('#tabbereditfile-association').prepend(error_msg);
530 jQuery('#editdocdata').attr('action', this.docparams.action);
532 jQuery.get(this.docparams.docManURL+'/', {
533 group_id: this.docparams.groupId,
537 itemid: this.docparams.docgroupId,
538 childgroup_id: this.docparams.childGroupId,
541 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+", rqd:"+nocache+"})", this.docparams.lockIntervalDelay);
542 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+", rqd:"+nocache+"})", this.docparams.lockIntervalDelay);
543 jQuery('#tabbereditfile').tabs("option", "active", 0);
544 this.setRequiredInputs(jQuery('#versiontab'));
545 jQuery(this.listfileparams.divEditFile).dialog('option', 'title', '[D'+this.docparams.id+'] '+this.listfileparams.divEditTitle).dialog('open');
549 toggleAddVersionView: function() {
550 jQuery('#title').val('');
551 jQuery('#description').val('');
552 jQuery(':file').val('');
553 jQuery('#edit_version').val('');
554 jQuery('#defaulteditzone').text();
555 jQuery('#current_version').prop('checked', false);
556 jQuery('#current_version').attr('onclick', 'return true');
557 if (!this.listfileparams.tableAddVersion.is(':visible')) {
558 jQuery('#new_version').val(1);
559 this.listfileparams.tableAddVersion.show();
561 this.listfileparams.tableAddVersion.hide();
562 jQuery('#new_version').val(0);
566 toggleAddReviewView: function() {
567 jQuery('#review_newcomment').val(0);
568 jQuery('#review-title').val('');
569 jQuery('#review-description').val('');
570 jQuery('#review-notificationcomment').val('');
571 jQuery('#datepicker_end_review_date').val('');
572 jQuery('#review-serialid').val();
573 jQuery('[class^=gentle]').remove();
574 jQuery('#review-select-mandatory-users').val('');
575 jQuery('#review-select-optional-users').val('');
576 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
577 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
578 jQuery('#editfile-userstatusreview').empty();
579 jQuery('#editfile-completedreview').empty();
580 jQuery('#editfile-commentreview').empty();
581 jQuery('#editfile-remindernotification').hide();
582 jQuery('#review-remindernotification').val('');
583 if (jQuery('#editfile-createreview').is(':visible')) {
584 jQuery('#editfile-createreview').hide();
585 jQuery('#new_review').val(0);
587 jQuery('#new_review').val(1);
588 jQuery('#editfile-createreview').show();
589 jQuery('#review-notificationcomment-row').show();
593 toggleEditReviewView: function(params) {
594 this.review = params;
595 jQuery('#editfile-commentreview').empty();
596 jQuery('#review_newcomment').val(0);
597 jQuery('#editfile-remindernotification').hide();
598 jQuery('#review-remindernotification').val('');
599 if (jQuery('#editfile-createreview').is(':visible')) {
600 jQuery('#editfile-createreview').hide();
601 jQuery('#new_review').val(0);
602 jQuery('#review_id').val(0);
603 jQuery('#review_complete').val(0);
604 jQuery('#editfile-userstatusreview').empty();
605 jQuery('#editfile-completedreview').empty();
607 jQuery('#review_id').val(this.review.review);
608 jQuery('#review-title').val(this.review.title);
609 jQuery('#review-description').val(this.review.description.replace(/\\n/g, String.fromCharCode(13,10)));
610 jQuery('#datepicker_end_review_date').val(this.review.endreviewdate);
611 jQuery('#review-serialid').val(this.review.serialid);
612 var nocache = new Date().getTime();
613 if (this.review.complete) {
614 jQuery('#tr-mandatory-reviewers').hide();
615 jQuery('#tr-optional-reviewers').hide();
616 jQuery('#review_complete').val(1);
617 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.review.groupId + '&action=getdocreviewcompleteform&docid='+this.review.docid+'&revid='+this.review.review+'&rqd='+nocache, jQuery.proxy(function(data){
618 jQuery('#editfile-completedreview').empty();
619 if (typeof data.html != 'undefined') {
620 jQuery('#editfile-completedreview').prepend(data.html);
622 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
623 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
624 jQuery('#editfile-completedreview').prepend(error_msg);
627 jQuery('#tr-mandatory-reviewers').show();
628 jQuery('#tr-optional-reviewers').show();
629 jQuery('[class^=gentle]').remove();
630 jQuery('#review-select-mandatory-users').val(this.review.mandatoryusers);
631 jQuery('#review-select-optional-users').val(this.review.optionalusers);
632 jQuery('#review-select-mandatory-users').gentleSelect({columns: 3, itemWidth: 150});
633 jQuery('#review-select-optional-users').gentleSelect({columns: 3, itemWidth: 150});
635 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.review.groupId + '&action=getdocreviewuserstatus&docid='+this.review.docid+'&revid='+this.review.review+'&rqd='+nocache, jQuery.proxy(function(data){
636 jQuery('#editfile-userstatusreview').empty();
637 if (typeof data.html != 'undefined') {
638 jQuery('#editfile-userstatusreview').prepend(data.html);
640 }, this.review)).fail(function(jqXHR, textStatus, errorThrown) {
641 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
642 jQuery('#editfile-userstatusreview').prepend(error_msg);
644 jQuery('#new_review').val(0);
645 jQuery('#editfile-createreview').show();
646 jQuery('#review-notificationcomment-row').hide();
650 toggleCommentReviewView: function(params) {
651 this.comment = params;
652 jQuery('#editfile-createreview').hide();
653 jQuery('#new_review').val(0);
654 jQuery('#review_id').val(0);
655 jQuery('#review_complete').val(0);
656 jQuery('#review_newcomment').val(1);
657 jQuery('#review_id').val(this.comment.review);
658 jQuery('#editfile-userstatusreview').empty();
659 jQuery('#editfile-completedreview').empty();
660 jQuery('#editfile-remindernotification').hide();
661 jQuery('#review-remindernotification').val('');
662 var nocache = new Date().getTime();
663 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.comment.groupId + '&action=getdocreviewcomments&docid='+this.comment.docid+'&revid='+this.comment.review+'&rqd='+nocache, jQuery.proxy(function(data){
664 jQuery('#editfile-commentreview').empty();
665 if (typeof data.html != 'undefined') {
666 jQuery('#editfile-commentreview').prepend(data.html);
668 }, this.comment)).fail(function(jqXHR, textStatus, errorThrown) {
669 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
670 jQuery('#editfile-commentreview').prepend(error_msg);
674 toggleEditVersionView: function(params) {
675 this.version = params;
676 jQuery('#new_version').val(0);
677 if (this.version.isHtml) {
678 jQuery('#defaulteditfiletype').val('text/html');
680 if (this.version.isText && !this.version.isHtml) {
681 jQuery('#defaulteditfiletype').val('text/plain');
683 if (this.version.isText) {
684 var nocache = new Date().getTime();
685 jQuery.getJSON(this.listfileparams.docManURL+'/?group_id='+this.version.groupId+'&action=getfile&type=file&itemid='+this.version.id+'&version='+this.version.version+'&rqd='+nocache, jQuery.proxy(function(data){
687 jQuery('#defaulteditzone').text(data.body);
689 }, this)).fail(function(jqXHR, textStatus, errorThrown) {
690 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
691 jQuery('#defaulteditzone').prepend(error_msg);
695 if (!this.listfileparams.tableAddVersion.is(':visible')) {
696 if (this.version.isURL) {
697 jQuery('#uploadnewroweditfile').hide();
698 jQuery('#fileurlroweditfile').show();
699 jQuery('#fileurlroweditfile').find('input').attr('required', 'required').prop('required', true);
700 jQuery('#fileurlroweditfile').find('input').val(this.version.filename);
701 jQuery('#editonlineroweditfile').hide();
702 jQuery('#editor').attr('disabled', true);
703 jQuery('#editButtonUrl').prop('checked', true);
704 } else if (this.listfileparams.useCreateOnline && this.version.isText){
705 jQuery('#fileurlroweditfile').hide();
706 jQuery('#uploadnewroweditfile').hide();
707 jQuery('#editonlineroweditfile').show();
708 jQuery('#editor').removeAttr('disabled');
709 jQuery('#editButtonEditor').prop('checked', true);
711 jQuery('#onlineroweditfile').hide();
712 jQuery('#editor').attr('disabled', true);
713 jQuery('#fileurlroweditfile').hide();
714 jQuery('#uploadnewroweditfile').show();
715 jQuery('#editButtonFile').prop('checked', true);
717 jQuery('#title').val(this.version.title);
718 jQuery('#description').val(this.version.description.replace(/\\n/g, String.fromCharCode(13,10)));
719 jQuery('#vcomment').val(this.version.vcomment.replace(/\\n/g, String.fromCharCode(13,10)));
720 jQuery('#edit_version').val(this.version.version);
721 if (this.version.current_version == 1) {
722 jQuery('#current_version').attr('checked', 'checked').prop('checked', true);
723 jQuery('#current_version').attr('onclick', 'return false');
725 this.listfileparams.tableAddVersion.show();
727 this.listfileparams.tableAddVersion.hide();
728 jQuery('#title').val('');
729 jQuery('#description').val('');
730 jQuery('#vcomment').val('');
731 jQuery(':file').val('');
732 jQuery('#edit_version').val('');
733 jQuery('#current_version').removeAttr('checked');
734 jQuery('#current_version').attr('onclick', 'return true');
735 jQuery('#fileurlroweditfile').find('input').val('');
736 jQuery('#fileurlroweditfile').find('input').removeAttr('required');
737 jQuery('#fileurlroweditfile').hide();
738 jQuery('#uploadnewroweditfile').hide();
739 jQuery('#editonlineroweditfile').hide();
740 jQuery('#defaulteditzone').text('');
744 deleteVersion: function(params) {
745 this.delversion = params;
746 var nocache = new Date().getTime();
747 jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + this.delversion.groupId + '&action=deleteversion&docid='+this.delversion.docid+'&version='+this.delversion.version+'&rqd='+nocache, jQuery.proxy(function(data){
748 if (typeof data.html != 'undefined') {
749 jQuery('#editFile > .feedback').remove();
750 jQuery('#editFile > .error').remove();
751 jQuery('#editFile > .warning_msg').remove();
752 jQuery('#editFile').prepend(data.html);
754 if (typeof data.status != 'undefined') {
755 if (data.status == 1) {
756 jQuery('#docversion'+this.version).remove();
757 //adjust review tab & version tab number?
758 if (jQuery('#docversionreview'+this.version) != 'undefined') {
759 jQuery('#docversionreview'+this.version).parent.remove();
761 if (jQuery('#sortable_doc_version_table tr').length <= 2) {
762 jQuery('#version_action_delete').remove();
766 }, this.delversion)).fail(function(jqXHR, textStatus, errorThrown) {
767 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
768 jQuery('#editFile').prepend(error_msg);
772 deleteReview: function(params) {
773 this.delreview = params;
774 jQuery('#editfile-createreview').hide();
775 jQuery('#new_review').val(0);
776 jQuery('#review_id').val(0);
777 jQuery('#review_complete').val(0);
778 jQuery('#editfile-userstatusreview').empty();
779 jQuery('#editfile-completedreview').empty();
780 jQuery('#editfile-remindernotification').hide();
781 jQuery('#review-remindernotification').val('');
782 var nocache = new Date().getTime();
783 jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=deletereview&docid='+this.docparams.id+'&review='+this.delreview.review+'&rqd='+nocache, jQuery.proxy(function(data){
784 if (typeof data.html != 'undefined') {
785 jQuery('#editFile > .feedback').remove();
786 jQuery('#editFile > .error').remove();
787 jQuery('#editFile > .warning_msg').remove();
788 jQuery('#editFile').prepend(data.html);
790 if (typeof data.status != 'undefined') {
791 if (data.status == 1) {
792 jQuery('#docreview'+this.review).remove();
793 //adjust review tab number?
796 }, this.delreview)).fail(function(jqXHR, textStatus, errorThrown) {
797 error_msg = jQuery('<p class="error">'+textStatus+': Unable to contact server.</p>');
798 jQuery('#editFile').prepend(error_msg);
802 reminderReview: function(params) {
803 this.reminderreview = params;
804 if (jQuery('#editfile-remindernotification').is(':visible')) {
805 jQuery('#editfile-remindernotification').hide();
806 jQuery('#review-remindernotification').val('');
808 jQuery('#new_review').val(2);
809 jQuery('#review_id').val(this.reminderreview.review);
810 jQuery('#editfile-createreview').hide();
811 jQuery('#editfile-commentreview').empty();
812 jQuery('#editfile-userstatusreview').empty();
813 jQuery('#editfile-completedreview').empty();
814 jQuery('#editfile-remindernotification').show();
818 toggleMoveFileView: function() {
819 if (!this.listfileparams.divMoveFile.is(':visible')) {
820 this.listfileparams.divMoveFile.show();
821 jQuery('#movefileinput').val(function() {
822 var CheckedBoxes = new Array();
823 for (var h = 0; h < jQuery('input:checked').length; h++) {
824 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocidactive')) {
825 CheckedBoxes.push(jQuery('input:checked')[h].value);
831 this.listfileparams.divMoveFile.hide();
835 toggleNotifyUserView: function(params) {
836 this.notifyparams = params;
837 var nocache = new Date().getTime();
838 jQuery('#notifytitle').text(this.notifyparams.title);
839 jQuery('#notifydescription').text(this.notifyparams.description);
840 jQuery('#notifydocid').val(this.notifyparams.id);
841 jQuery('#notifyfilelink').text(this.notifyparams.filename);
842 if (this.notifyparams.statusId != 2) {
843 if (this.notifyparams.isURL) {
844 jQuery('#notifyfilelink').attr('href', this.notifyparams.filename);
846 jQuery('#notifyfilelink').attr('href', this.notifyparams.docManURL+'/view.php/'+this.notifyparams.groupId+'/'+this.notifyparams.id);
850 jQuery('#notifyusersdoc').attr('action', this.notifyparams.action);
851 jQuery.get(this.notifyparams.docManURL+'/', {
852 group_id: this.notifyparams.groupId,
856 itemid: this.notifyparams.docgroupId,
857 childgroup_id: this.notifyparams.childGroupId,
860 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+", rqd:"+nocache+"})", this.notifyparams.lockIntervalDelay);
861 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+", rqd:"+nocache+"})", this.notifyparams.lockIntervalDelay);
862 jQuery('#notify-userids').gentleSelect({columns: 2, itemWidth: 120});
863 jQuery(this.listfileparams.divNotifyUsers).dialog('option', 'title', '[D'+this.notifyparams.id+'] '+this.listfileparams.divNotifyTitle).dialog('open');
869 /*! build list of id, comma separated
871 buildUrlByCheckbox: function(id) {
872 var CheckedBoxes = new Array();
873 for (var h = 0; h < jQuery('input:checked').length; h++) {
874 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocid'+id)) {
875 CheckedBoxes.push(jQuery('input:checked')[h].value);
881 checkAll: function(id, type) {
882 if (jQuery('#checkall'+type).is(':checked')) {
883 jQuery('.'+id).each(function() {
884 jQuery(this).prop('checked', true);
886 jQuery('#massaction'+type).show();
888 jQuery('.'+id).each(function() {
889 jQuery(this).prop('checked', false);
891 jQuery('#massaction'+type).hide();
895 checkgeneral: function(id) {
896 if (jQuery(this).attr('checked', false)) {
897 jQuery('#checkall'+id).prop('checked', false);
898 jQuery('#massaction'+id).hide();
899 jQuery('#movefile').hide();
901 for (var h = 0; h < jQuery('input:checked').length; h++) {
902 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkeddocid'+id)) {
903 jQuery('#massaction'+id).show();
909 setRequiredInputs: function(id) {
910 if (id.attr('id') == 'reviewtab') {
911 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
912 jQuery('#tabbereditfile-association').prop('disabled', true);
913 jQuery('#tabbereditfile-review :input').removeAttr('disabled');
914 jQuery('#subaction').val('review');
915 } else if (id.attr('id') == 'associationtab') {
916 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').prop('disabled', true);
917 jQuery('#tabbereditfile-association').removeAttr('disabled');
918 jQuery('#tabbereditfile-review :input').prop('disabled', true);
919 jQuery('#subaction').val('association');
920 } else if (id.attr('id') == 'versiontab') {
921 jQuery('#tabbereditfile-version :input').not(':input[type=hidden], :input[type=button]').removeAttr('disabled');
922 jQuery('#tabbereditfile-association').prop('disabled', true);
923 jQuery('#tabbereditfile-review :input').prop('disabled', true);
924 jQuery('#subaction').val('version');
929 DocManAddItemController.prototype =
931 /*! Binds the controls to the actions
933 bindControls: function() {
934 this.additemparams.submitZip.click(jQuery.proxy(this, "submitFormZip"));
937 submitFormZip: function() {
938 this.additemparams.injectZip.submit();
939 this.additemparams.submitZip.attr('disabled', true);
943 DocManAddFileController.prototype =
945 /*! Binds the controls to the actions
947 bindControls: function() {
948 this.addfileparams.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
949 this.addfileparams.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
950 if (typeof(this.addfileparams.buttonManualUpload) != 'undefined') {
951 this.addfileparams.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
953 if (typeof(this.addfileparams.buttonEditor) != 'undefined') {
954 this.addfileparams.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
958 toggleFileRowView: function() {
959 this.addfileparams.fileRow.show();
960 this.addfileparams.fileRow.find('input').attr("required", "required");
961 this.addfileparams.urlRow.hide();
962 this.addfileparams.urlRow.find('input').removeAttr("required");
963 this.addfileparams.pathRow.hide();
964 this.addfileparams.pathRow.find('input').removeAttr("required");
965 this.addfileparams.editRow.hide();
966 this.addfileparams.editNameRow.hide();
969 toggleUrlRowView: function() {
970 this.addfileparams.fileRow.hide();
971 this.addfileparams.fileRow.find('input').removeAttr("required");
972 this.addfileparams.urlRow.show();
973 this.addfileparams.urlRow.find('input').attr("required", "required");
974 this.addfileparams.pathRow.hide();
975 this.addfileparams.pathRow.find('input').removeAttr("required");
976 this.addfileparams.editRow.hide();
977 this.addfileparams.editNameRow.hide();
980 toggleManualUploadView: function() {
981 this.addfileparams.fileRow.hide();
982 this.addfileparams.fileRow.find('input').removeAttr("required");
983 this.addfileparams.urlRow.hide();
984 this.addfileparams.urlRow.find('input').removeAttr("required");
985 this.addfileparams.pathRow.show();
986 this.addfileparams.pathRow.find('input').attr("required", "required");
987 this.addfileparams.editRow.hide();
988 this.addfileparams.editNameRow.hide();
991 toggleEditorView: function() {
992 this.addfileparams.fileRow.hide();
993 this.addfileparams.fileRow.find('input').removeAttr("required");
994 this.addfileparams.urlRow.hide();
995 this.addfileparams.urlRow.find('input').removeAttr("required");
996 this.addfileparams.pathRow.hide();
997 this.addfileparams.pathRow.find('input').removeAttr("required");
998 this.addfileparams.editRow.show();
999 this.addfileparams.editNameRow.show();
1003 DocManSearchController.prototype =
1005 /*! Binds the controls to the actions
1007 bindControls: function() {
1008 this.searchparams.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
1009 this.searchparams.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
1012 setStartDate: function() {
1013 if (this.searchparams.buttonStartDate.is(':checked')) {
1014 this.searchparams.datePickerStartDate.removeAttr('disabled');
1015 this.searchparams.datePickerStartDate.attr('required', 'required');
1017 this.searchparams.datePickerStartDate.attr('disabled', 'disabled');
1018 this.searchparams.datePickerStartDate.removeAttr('required');
1022 setEndDate: function() {
1023 if (this.searchparams.buttonEndDate.is(':checked')) {
1024 this.searchparams.datePickerEndDate.removeAttr('disabled');
1025 this.searchparams.datePickerEndDate.attr('required', 'required');
1027 this.searchparams.datePickerEndDate.attr('disabled', 'disabled');
1028 this.searchparams.datePickerEndDate.removeAttr('required');