2 * FusionForge Documentation Manager
4 * Copyright 2010, Antoine Mercadal - Capgemini
5 * Copyright 2010-2011, Franck Villaume - Capgemini
6 * Copyright 2011, Franck Villaume - TrivialDev
7 * Copyright 2011, Alain Peyrat
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 = [];
38 DocManAddItemController = function(params)
44 DocManListFileController.prototype =
46 /*! Binds the controls to the actions
48 bindControls: function() {
49 if (typeof(this.params.buttonEditDirectory) != 'undefined') {
50 this.params.buttonEditDirectory.click(jQuery.proxy(this, "toggleEditDirectoryView"));
52 if (typeof(this.params.buttonAddItem) != 'undefined') {
53 this.params.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
57 resizableDiv:function() {
58 if (typeof(this.params.divHandle) != 'undefined') {
59 this.params.divHandle.mousedown(jQuery.proxy(this, "dragging"));
60 var params = this.params;
61 var w = jQuery('#maindiv').width() - this.params.divHandle.width() - 70;
62 jQuery(document).mouseup(function(){isDragging = false;}).mousemove(function(e){
63 if (typeof(isDragging) != 'undefined') {
65 params.divLeft.css('width', e.pageX);
66 params.divRight.css('width', w - e.pageX);
67 jQuery.Storage.set("treesize",""+params.divLeft.width());
75 if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
76 if (this.params.divLeft.height() > this.params.divRight.height()) {
77 this.params.divHandle.css('height', this.params.divLeft.height());
79 this.params.divHandle.css('height', this.params.divRight.height());
81 if (jQuery.Storage.get("treesize") != 0) {
82 this.params.divLeft.css('width', parseInt(jQuery.Storage.get("treesize")));
83 var w = jQuery('#maindiv').width() - this.params.divHandle.width() - 70;
84 this.params.divRight.css('width', w - this.params.divLeft.width());
89 dragging: function() {
93 /*! toggle edit group view div visibility
95 toggleEditDirectoryView: function() {
96 if (!this.params.divEditDirectory.is(":visible")) {
97 this.params.divEditDirectory.show();
98 if (typeof(this.params.divAddItem) != 'undefined') {
99 this.params.divAddItem.hide();
102 this.params.divEditDirectory.hide();
104 if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
105 if (this.params.divLeft.height() > this.params.divRight.height()) {
106 this.params.divHandle.css('height', this.params.divLeft.height());
108 this.params.divHandle.css('height', this.params.divRight.height());
114 /*! toggle add item view div visibility
116 toggleAddItemView: function() {
117 if (!this.params.divAddItem.is(":visible")) {
118 this.params.divAddItem.show();
119 this.params.divEditDirectory.hide();
121 this.params.divAddItem.hide();
123 if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
124 if (this.params.divLeft.height() > this.params.divRight.height()) {
125 this.params.divHandle.css('height', this.params.divLeft.height());
127 this.params.divHandle.css('height', this.params.divRight.height());
133 /*! toggle add file edit view div visibility and play with lock
135 * @param string id of the div
137 toggleEditFileView: function(id) {
138 var divid = '#docid'+id,
141 if (!el.is(":visible")) {
144 jQuery.get(this.params.docManURL, {
145 group_id: this.params.groupId,
149 childgroup_id: this.params.childGroupId
152 this.lockInterval[id] = setInterval("jQuery.get('" + this.params.docManURL + "', {group_id:"+this.params.groupId+",action:'lockfile',lock:1,fileid:"+id+",childgroup_id:"+this.params.childGroupId+"})",this.params.lockIntervalDelay);
155 jQuery.get(this.params.docManURL, {
156 group_id: this.params.groupId,
160 childgroup_id: this.params.childGroupId
163 clearInterval(this.lockInterval[id]);
165 if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
166 if (this.params.divLeft.height() > this.params.divRight.height()) {
167 this.params.divHandle.css('height', this.params.divLeft.height());
169 this.params.divHandle.css('height', this.params.divRight.height());
175 /*! build list of id, comma separated
177 buildUrlByCheckbox: function(id) {
178 var CheckedBoxes = new Array();
179 for (var h = 0; h < jQuery("input:checked").length; h++) {
180 if (typeof(jQuery("input:checked")[h].className) != "undefined" && jQuery("input:checked")[h].className.match('checkeddocid'+id)) {
181 CheckedBoxes.push(jQuery("input:checked")[h].value);
187 checkAll: function(id, type) {
188 if (jQuery('#checkall'+type).is(':checked')) {
189 jQuery('.'+id).each(function() {
190 jQuery(this).attr('checked', true);
192 jQuery('#massaction'+type).show();
194 jQuery('.'+id).each(function() {
195 jQuery(this).attr('checked', false);
197 jQuery('#massaction'+type).hide();
201 checkgeneral: function(id) {
202 if (jQuery(this).attr('checked', false)) {
203 jQuery('#checkall'+id).attr('checked', false);
204 jQuery('#massaction'+id).hide();
206 for (var h = 0; h < jQuery("input:checked").length; h++) {
207 console.log("%s", jQuery("input:checked")[h].className);
208 if (typeof(jQuery("input:checked")[h].className) != "undefined" && jQuery("input:checked")[h].className.match('checkeddocid'+id)) {
209 jQuery('#massaction'+id).show();
214 computeDocumentsData: function() {
217 build the array in php is not dynamic, and clearly, this sucks.
218 It would be better to be able to ask JSON data containing the contents of a dir
219 etc. and compute this data with Javascript in order to build the table.
220 This will avoids to reload the page when you simply want to lock / remove / add a file etc.
225 DocManAddItemController.prototype =
227 /*! Binds the controls to the actions
229 bindControls: function() {
230 this.params.buttonDoc.click(jQuery.proxy(this, "toggleAddFileView"));
231 this.params.buttonDir.click(jQuery.proxy(this, "toggleAddDirectoryView"));
232 this.params.buttonZip.click(jQuery.proxy(this, "toggleInjectZipView"));
235 toggleAddDirectoryView: function() {
236 if (!this.params.divCreateDir.is(":visible")) {
237 this.params.divCreateDir.show();
238 this.params.divCreateDoc.hide();
239 this.params.divZipInject.hide();
241 this.params.divCreateDoc.hide();
242 this.params.divZipInject.hide();
244 if (typeof(jQuery('#left')) != 'undefined' && typeof(jQuery('#right')) != 'undefined') {
245 if (jQuery('#left').height() > jQuery('#right').height()) {
246 jQuery('#handle').css('height', jQuery('#left').height());
248 jQuery('#handle').css('height', jQuery('#right').height());
253 toggleInjectZipView: function() {
254 if (!this.params.divZipInject.is(":visible")) {
255 this.params.divZipInject.show();
256 this.params.divCreateDir.hide();
257 this.params.divCreateDoc.hide();
259 this.params.divCreateDir.hide();
260 this.params.divCreateDoc.hide();
262 if (typeof(jQuery('#left')) != 'undefined' && typeof(jQuery('#right')) != 'undefined') {
263 if (jQuery('#left').height() > jQuery('#right').height()) {
264 jQuery('#handle').css('height', jQuery('#left').height());
266 jQuery('#handle').css('height', jQuery('#right').height());
271 toggleAddFileView: function() {
272 if (!this.params.divCreateDoc.is(":visible")) {
273 this.params.divCreateDoc.show();
274 this.params.divCreateDir.hide();
275 this.params.divZipInject.hide();
277 this.params.divCreateDir.hide();
278 this.params.divZipInject.hide();
280 if (typeof(jQuery('#left')) != 'undefined' && typeof(jQuery('#right')) != 'undefined') {
281 if (jQuery('#left').height() > jQuery('#right').height()) {
282 jQuery('#handle').css('height', jQuery('#left').height());
284 jQuery('#handle').css('height', jQuery('#right').height());