# HG changeset patch # User gibus # Date 1291107215 -3600 # Node ID 053551f213fbc9d12757b8f97540ecac163607b0 # Parent 9e2b9e568e42a8e85ed86e37ece69813c31009df Coding style for js: expand tabs diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_addcomment_form.js --- a/src/cm/media/js/client/c_addcomment_form.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_addcomment_form.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,200 +1,200 @@ gICommentForm = null ; instanciateICommentForm = function() { - gICommentForm = { - 'position':[CY.WidgetPositionExt.LC, CY.WidgetPositionExt.LC], - 'formId':CY.guid(), - 'formTitleId':CY.guid(), - 'titleInputId':CY.guid(), - 'contentInputId':CY.guid(), - 'tagsInputId':CY.guid(), - 'formatInputId':CY.guid(), - 'startWrapperInputId':CY.guid(), - 'endWrapperInputId':CY.guid(), - 'startOffsetInputId':CY.guid(), - 'endOffsetInputId':CY.guid(), - 'selectionPlaceId':CY.guid(), - 'keyId':CY.guid(), - 'currentSelId':CY.guid(), - 'currentSelIdI':CY.guid(), - 'addBtnId':CY.guid(), - 'cancelBtnId':CY.guid(), - 'closeBtnId':CY.guid() - } ; - - if (!sv_loggedIn) { - gICommentForm ['nameInputId'] = CY.guid() ; - gICommentForm ['emailInputId'] = CY.guid() ; - } - - var overlayHtml = getHtml(gICommentForm) ; - - var width = gLayout.getTopICommentsWidth() ; - - var overlay = new CY.Overlay( { - zIndex :3, - shim :false, // until we really need it, no shim - visible :false, - headerContent :overlayHtml['headerContent'], - bodyContent :overlayHtml['bodyContent'], - xy :[10,10], - width : width - }); - overlay.get('contentBox').addClass("c-newcomment") ; - - // attach to DOM - overlay.render('#leftcolumn'); - - if (!sv_loggedIn) { - CY.get("#"+gICommentForm['nameInputId']).set('value',gPrefs.get("user","name")) ; - CY.get("#"+gICommentForm['emailInputId']).set('value',gPrefs.get("user","email")) ; - } - - CY.get("#"+gICommentForm['formTitleId']).set('innerHTML', gettext('New comment')) ; - CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ; - - CY.on("click", onSubmitICommentFormClick, "#"+gICommentForm['addBtnId']); - CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['cancelBtnId']); - CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['closeBtnId']); - - gICommentForm['overlay'] = overlay ; - - var animationHide = null ; - animationHide = new CY.Anim({ + gICommentForm = { + 'position':[CY.WidgetPositionExt.LC, CY.WidgetPositionExt.LC], + 'formId':CY.guid(), + 'formTitleId':CY.guid(), + 'titleInputId':CY.guid(), + 'contentInputId':CY.guid(), + 'tagsInputId':CY.guid(), + 'formatInputId':CY.guid(), + 'startWrapperInputId':CY.guid(), + 'endWrapperInputId':CY.guid(), + 'startOffsetInputId':CY.guid(), + 'endOffsetInputId':CY.guid(), + 'selectionPlaceId':CY.guid(), + 'keyId':CY.guid(), + 'currentSelId':CY.guid(), + 'currentSelIdI':CY.guid(), + 'addBtnId':CY.guid(), + 'cancelBtnId':CY.guid(), + 'closeBtnId':CY.guid() + } ; + + if (!sv_loggedIn) { + gICommentForm ['nameInputId'] = CY.guid() ; + gICommentForm ['emailInputId'] = CY.guid() ; + } + + var overlayHtml = getHtml(gICommentForm) ; + + var width = gLayout.getTopICommentsWidth() ; + + var overlay = new CY.Overlay( { + zIndex :3, + shim :false, // until we really need it, no shim + visible :false, + headerContent :overlayHtml['headerContent'], + bodyContent :overlayHtml['bodyContent'], + xy :[10,10], + width : width + }); + overlay.get('contentBox').addClass("c-newcomment") ; + + // attach to DOM + overlay.render('#leftcolumn'); + + if (!sv_loggedIn) { + CY.get("#"+gICommentForm['nameInputId']).set('value',gPrefs.get("user","name")) ; + CY.get("#"+gICommentForm['emailInputId']).set('value',gPrefs.get("user","email")) ; + } + + CY.get("#"+gICommentForm['formTitleId']).set('innerHTML', gettext('New comment')) ; + CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ; + + CY.on("click", onSubmitICommentFormClick, "#"+gICommentForm['addBtnId']); + CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['cancelBtnId']); + CY.on("click", onCancelICommentFormClick, "#"+gICommentForm['closeBtnId']); + + gICommentForm['overlay'] = overlay ; + + var animationHide = null ; + animationHide = new CY.Anim({ node: overlay.get('boundingBox'), duration: .3, //gPrefs['general']['animduration'], easing: CY.Easing.easeOut - }); - gICommentForm['animationHide'] = animationHide ; - animationHide.set('to', { opacity: 0});// height : 0 doesn't work - gICommentForm['animationHide-handle'] = animationHide.on('end', onICommentFormHideAnimEnd, gICommentForm); + }); + gICommentForm['animationHide'] = animationHide ; + animationHide.set('to', { opacity: 0});// height : 0 doesn't work + gICommentForm['animationHide-handle'] = animationHide.on('end', onICommentFormHideAnimEnd, gICommentForm); - var animationShow = null ; - animationShow = new CY.Anim({ + var animationShow = null ; + animationShow = new CY.Anim({ node: overlay.get('boundingBox'), duration: .3, //gPrefs['general']['animduration'], easing: CY.Easing.easeOut - }); - gICommentForm['animationShow'] = animationShow ; - animationShow.set('to', { opacity: 1}); - gICommentForm['animationShow-handle'] = animationShow.on('end', onICommentFormShowAnimEnd, gICommentForm); - - changeFormFieldsWidth(gICommentForm['formId'], width) ; + }); + gICommentForm['animationShow'] = animationShow ; + animationShow.set('to', { opacity: 1}); + gICommentForm['animationShow-handle'] = animationShow.on('end', onICommentFormShowAnimEnd, gICommentForm); + + changeFormFieldsWidth(gICommentForm['formId'], width) ; } cleanICommentForm = function() { - CY.get("#"+gICommentForm['currentSelIdI']).set('innerHTML', gNoSelectionYet) ; + CY.get("#"+gICommentForm['currentSelIdI']).set('innerHTML', gNoSelectionYet) ; var hostNode = gICommentForm['overlay'].getStdModNode(CY.WidgetStdMod.BODY) ; hostNode.queryAll(".comment_input").set('value', "") ; - - CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ... - - if (!sv_loggedIn) { - hostNode.queryAll(".user_input").set('value', "") ; - } + + CY.get("#"+gICommentForm['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ... + + if (!sv_loggedIn) { + hostNode.queryAll(".user_input").set('value', "") ; + } } onICommentFormHideAnimEnd = function() { -// iComment['overlay'].blur() ; - this.overlay.hide() ; - gSync.resume() ; +// iComment['overlay'].blur() ; + this.overlay.hide() ; + gSync.resume() ; } onICommentFormShowAnimEnd = function() { - gSync.resume() ; + gSync.resume() ; } onSubmitICommentFormClick = function() { - if (!sv_loggedIn) { - var name = CY.get("#"+gICommentForm['nameInputId']).get('value') ; - gPrefs.persist("user", "name", name) ; - - var email = CY.get("#"+gICommentForm['emailInputId']).get('value') ; - gPrefs.persist("user", "email", email) ; - } - gSync.saveComment(gICommentForm['formId']) ; + if (!sv_loggedIn) { + var name = CY.get("#"+gICommentForm['nameInputId']).get('value') ; + gPrefs.persist("user", "name", name) ; + + var email = CY.get("#"+gICommentForm['emailInputId']).get('value') ; + gPrefs.persist("user", "email", email) ; + } + gSync.saveComment(gICommentForm['formId']) ; } onCancelICommentFormClick = function() { - gSync.cancelICommentForm() ; + gSync.cancelICommentForm() ; } // record selection info in hidden form fields _updateICommentFormSelection = function(ids, displayedText, csStartSelection, csEndSelection) { - var node = CY.Node.get('#'+ids['currentSelIdI']) ; - if (node != null) - node.set('innerHTML', displayedText) ; - + var node = CY.Node.get('#'+ids['currentSelIdI']) ; + if (node != null) + node.set('innerHTML', displayedText) ; + node = CY.get('#'+ids['startWrapperInputId']) ; - if (node != null) - node.set('value', csStartSelection['elt'].id.substring("sv_".length)) ; + if (node != null) + node.set('value', csStartSelection['elt'].id.substring("sv_".length)) ; node = CY.get('#'+ids['startOffsetInputId']) ; - if (node != null) - node.set('value', csStartSelection['offset']) ; + if (node != null) + node.set('value', csStartSelection['offset']) ; node = CY.get('#'+ids['endWrapperInputId']) ; - if (node != null) - node.set('value', csEndSelection['elt'].id.substring("sv_".length)) ; + if (node != null) + node.set('value', csEndSelection['elt'].id.substring("sv_".length)) ; node = CY.get('#'+ids['endOffsetInputId']) ; - if (node != null) - node.set('value', csEndSelection['offset']) ; + if (node != null) + node.set('value', csEndSelection['offset']) ; } updateICommentFormSelection = function(selection) { - var text = (selection == null) ? "" : selection['text'] ; - if (text != "") { - // display text to be commented - var displayedText = text ; - var maxLength = 100 ; // even number only - if (text.length > maxLength ) { - var start = text.substring(0, (text.substring(0, maxLength/2)).lastIndexOf(" ")) ; - var endPart = text.substring(text.length - maxLength/2) ; - var end = endPart.substring(endPart.indexOf(" ")) ; - displayedText = start + " ... " + end ; - } + var text = (selection == null) ? "" : selection['text'] ; + if (text != "") { + // display text to be commented + var displayedText = text ; + var maxLength = 100 ; // even number only + if (text.length > maxLength ) { + var start = text.substring(0, (text.substring(0, maxLength/2)).lastIndexOf(" ")) ; + var endPart = text.substring(text.length - maxLength/2) ; + var end = endPart.substring(endPart.indexOf(" ")) ; + displayedText = start + " ... " + end ; + } var csStartSelection = _convertSelectionFromCCToCS(selection['start']) ; var csEndSelection = _convertSelectionFromCCToCS(selection['end']) ; _updateICommentFormSelection(gICommentForm, displayedText, csStartSelection, csEndSelection); if (gEdit != null) - _updateICommentFormSelection(gEdit['ids'], displayedText, csStartSelection, csEndSelection); - positionICommentForm() ; - } + _updateICommentFormSelection(gEdit['ids'], displayedText, csStartSelection, csEndSelection); + positionICommentForm() ; + } } showICommentForm= function () { - removeFormErrMsg(gICommentForm['formId']) ; - if (!sv_loggedIn) { - if (CY.get("#"+gICommentForm['nameInputId']).get('value') == '') - CY.get("#"+gICommentForm['nameInputId']).set('value', gPrefs.get('user','name')) ; - if (CY.get("#"+gICommentForm['emailInputId']).get('value') == '') - CY.get("#"+gICommentForm['emailInputId']).set('value', gPrefs.get('user','email')) ; - } - gIComments.hide() ; - positionICommentForm() ; - gICommentForm['overlay'].show() ; - CY.get("#"+gICommentForm['titleInputId']).focus() ; + removeFormErrMsg(gICommentForm['formId']) ; + if (!sv_loggedIn) { + if (CY.get("#"+gICommentForm['nameInputId']).get('value') == '') + CY.get("#"+gICommentForm['nameInputId']).set('value', gPrefs.get('user','name')) ; + if (CY.get("#"+gICommentForm['emailInputId']).get('value') == '') + CY.get("#"+gICommentForm['emailInputId']).set('value', gPrefs.get('user','email')) ; + } + gIComments.hide() ; + positionICommentForm() ; + gICommentForm['overlay'].show() ; + CY.get("#"+gICommentForm['titleInputId']).focus() ; } isICommentFormVisible = function () { - if (gICommentForm != null) - return gICommentForm['overlay'].get('visible') ; - return false ; + if (gICommentForm != null) + return gICommentForm['overlay'].get('visible') ; + return false ; } positionICommentForm = function () { - if (gICommentForm != null) { - var overlay = gICommentForm['overlay'] ; - var boundingBox = overlay.get('boundingBox') ; + if (gICommentForm != null) { + var overlay = gICommentForm['overlay'] ; + var boundingBox = overlay.get('boundingBox') ; - var commentFormHeight = boundingBox.get('offsetHeight') ; - var windowHeight = boundingBox.get('winHeight') ; + var commentFormHeight = boundingBox.get('offsetHeight') ; + var windowHeight = boundingBox.get('winHeight') ; - var pos = gICommentForm['position'] ; - if (commentFormHeight > windowHeight) // trying to have save comment visible ... : - pos = [CY.WidgetPositionExt.BL, CY.WidgetPositionExt.BL] ; - - overlay.set("align", {points:pos}); - boundingBox.setX(boundingBox.getX() + gConf['iCommentLeftPadding']); - } -} \ No newline at end of file + var pos = gICommentForm['position'] ; + if (commentFormHeight > windowHeight) // trying to have save comment visible ... : + pos = [CY.WidgetPositionExt.BL, CY.WidgetPositionExt.BL] ; + + overlay.set("align", {points:pos}); + boundingBox.setX(boundingBox.getX() + gConf['iCommentLeftPadding']); + } +} diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_db.js --- a/src/cm/media/js/client/c_db.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_db.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,132 +1,132 @@ Db = function() { - //initial comment db as objs (TREE LIKE MODEL : replies are included in comment.replies) - this.comments = null; // current set of (filtered) comments - this.allComments = null; // all server database comments + //initial comment db as objs (TREE LIKE MODEL : replies are included in comment.replies) + this.comments = null; // current set of (filtered) comments + this.allComments = null; // all server database comments - // obj - // keys : commentDbId as string - // values : comment db as obj - this.commentsByDbId = {}; - this.allCommentsByDbId = {}; - - // dictionary (always contains all comments (no reply) whatever the filter - // order key --> ordered array of comment ids (no reply) - this.ordered_comment_ids = {}; // all server database comments - + // obj + // keys : commentDbId as string + // values : comment db as obj + this.commentsByDbId = {}; + this.allCommentsByDbId = {}; + + // dictionary (always contains all comments (no reply) whatever the filter + // order key --> ordered array of comment ids (no reply) + this.ordered_comment_ids = {}; // all server database comments + } Db.prototype = { - + ////////////////////////////// -// CORE FUNCTIONS +// CORE FUNCTIONS ////////////////////////////// - init : function() { - // at first server side ordered comment by asc ids, replies by creation date : - this.allComments = CY.JSON.parse(sv_comments) ; - if (sv_read_only) { - this.initToReadOnly() ; - } - - this._computeAllCommentsByDbId() ; - - this._reorder() ; - }, - - _del : function (arr, dic, id) { - // first recursively remove all replies - var comment = dic[id] ; - - for (var i = 0 ; i < comment.replies.length ; i++) { - var rid = comment.replies[i].id ; - this._del(comment.replies, dic, rid) ; - i--; - } - - for (var i = 0, ilen = arr.length ; i < ilen ; i++) { - if (arr[i].id == id) { - arr.splice(i, 1) ; - delete dic[id] ; - break ; - } - } - }, + init : function() { + // at first server side ordered comment by asc ids, replies by creation date : + this.allComments = CY.JSON.parse(sv_comments) ; + if (sv_read_only) { + this.initToReadOnly() ; + } + + this._computeAllCommentsByDbId() ; + + this._reorder() ; + }, + + _del : function (arr, dic, id) { + // first recursively remove all replies + var comment = dic[id] ; + + for (var i = 0 ; i < comment.replies.length ; i++) { + var rid = comment.replies[i].id ; + this._del(comment.replies, dic, rid) ; + i--; + } + + for (var i = 0, ilen = arr.length ; i < ilen ; i++) { + if (arr[i].id == id) { + arr.splice(i, 1) ; + delete dic[id] ; + break ; + } + } + }, - del : function(comment) { - var arr = (comment.reply_to_id == null) ? this.comments : this.commentsByDbId[comment.reply_to_id].replies ; - this._del(arr, this.commentsByDbId, comment.id) ; - arr = (comment.reply_to_id == null) ? this.allComments : this.allCommentsByDbId[comment.reply_to_id].replies ; - this._del(arr, this.allCommentsByDbId, comment.id) ; - - this._reorder() ; - - }, - - // maintains the ordered lists - _reorder : function() { - - // scope (order by start_wrapper, start_offset, end_wrapper, end_offset - var a = [] ; - - for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { - - var comment = this.allComments[i] ; - var found = false ; + del : function(comment) { + var arr = (comment.reply_to_id == null) ? this.comments : this.commentsByDbId[comment.reply_to_id].replies ; + this._del(arr, this.commentsByDbId, comment.id) ; + arr = (comment.reply_to_id == null) ? this.allComments : this.allCommentsByDbId[comment.reply_to_id].replies ; + this._del(arr, this.allCommentsByDbId, comment.id) ; + + this._reorder() ; + + }, + + // maintains the ordered lists + _reorder : function() { + + // scope (order by start_wrapper, start_offset, end_wrapper, end_offset + var a = [] ; + + for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { + + var comment = this.allComments[i] ; + var found = false ; - for (var j = 0, jlen = a.length ; j < jlen ; j++) { - - var id = a[j] ; - var comment2 = this.allCommentsByDbId[id] ; - - if ((comment.start_wrapper < comment2.start_wrapper) - || - ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset < comment2.start_offset) ) - || - ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset == comment2.start_offset) && (comment.end_wrapper < comment2.end_wrapper) ) - || - ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset == comment2.start_offset) && (comment.end_wrapper == comment2.end_wrapper) && (comment.end_offset < comment2.end_offset) ) ) { - a.splice(j, 0, comment.id) ; - found = true ; - break ; - } - } - if (!found) { - a.push(comment.id) ; - } - } - this.ordered_comment_ids['scope'] = a ; - - // modified thread - a = [] ; - var mod = {} ; // we'll aggregate modification dates in this assoc array id --> latest modification - - for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { - - var comment = this.allComments[i] ; - var commentModif = comment.modified ; - + for (var j = 0, jlen = a.length ; j < jlen ; j++) { + + var id = a[j] ; + var comment2 = this.allCommentsByDbId[id] ; + + if ((comment.start_wrapper < comment2.start_wrapper) + || + ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset < comment2.start_offset) ) + || + ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset == comment2.start_offset) && (comment.end_wrapper < comment2.end_wrapper) ) + || + ((comment.start_wrapper == comment2.start_wrapper) && (comment.start_offset == comment2.start_offset) && (comment.end_wrapper == comment2.end_wrapper) && (comment.end_offset < comment2.end_offset) ) ) { + a.splice(j, 0, comment.id) ; + found = true ; + break ; + } + } + if (!found) { + a.push(comment.id) ; + } + } + this.ordered_comment_ids['scope'] = a ; + + // modified thread + a = [] ; + var mod = {} ; // we'll aggregate modification dates in this assoc array id --> latest modification + + for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { + + var comment = this.allComments[i] ; + var commentModif = comment.modified ; + mod[comment.id] = this._latest_mod(comment); - } - - for (var id in mod) { - var numberId = this.allCommentsByDbId[id].id - var found = false ; - for (var i = 0, ilen = a.length ; i < ilen ; i++) { - var id2 = a[i] ; - - if (mod[id] < mod[id2]) { - a.splice(i, 0, numberId) ; - found = true ; - break ; - } - - } - if (!found) { - a.push(numberId) ; - } - } - - this.ordered_comment_ids['modif_thread'] = a ; - }, + } + + for (var id in mod) { + var numberId = this.allCommentsByDbId[id].id + var found = false ; + for (var i = 0, ilen = a.length ; i < ilen ; i++) { + var id2 = a[i] ; + + if (mod[id] < mod[id2]) { + a.splice(i, 0, numberId) ; + found = true ; + break ; + } + + } + if (!found) { + a.push(numberId) ; + } + } + + this.ordered_comment_ids['modif_thread'] = a ; + }, // Finds recursively the last modification date of a thread. _latest_mod : function(comment) { @@ -140,401 +140,401 @@ return latest_mod; }, - // EDIT OR ADD CASE : when just added id is max and so both (comments and replies) initial id asc order remains - _upd : function(arr, dic, c) { - var found = false ; - for (var i = 0, ilen = arr.length ; i < ilen ; i++) { - if (arr[i].id == c.id) { // edit - arr.splice(i, 1, c) ; - found = true ; - break ; - } - } - - if (!found) { // add - arr.push(c) ; - } - - dic[c.id] = c ; - }, + // EDIT OR ADD CASE : when just added id is max and so both (comments and replies) initial id asc order remains + _upd : function(arr, dic, c) { + var found = false ; + for (var i = 0, ilen = arr.length ; i < ilen ; i++) { + if (arr[i].id == c.id) { // edit + arr.splice(i, 1, c) ; + found = true ; + break ; + } + } + + if (!found) { // add + arr.push(c) ; + } + + dic[c.id] = c ; + }, - // EDIT OR ADD CASE : when just added id is max and so both (comments and replies) initial id asc order respected - upd : function(comment) { - var arr = (comment.reply_to_id == null) ? this.allComments : this.allCommentsByDbId[comment.reply_to_id].replies ; - this._upd(arr, this.allCommentsByDbId, comment) ; - - var cloneComment = CY.clone(comment) ; - - arr = (comment.reply_to_id == null) ? this.comments : this.commentsByDbId[comment.reply_to_id].replies ; - this._upd(arr, this.commentsByDbId, cloneComment) ; - - this._reorder() ; - - }, + // EDIT OR ADD CASE : when just added id is max and so both (comments and replies) initial id asc order respected + upd : function(comment) { + var arr = (comment.reply_to_id == null) ? this.allComments : this.allCommentsByDbId[comment.reply_to_id].replies ; + this._upd(arr, this.allCommentsByDbId, comment) ; + + var cloneComment = CY.clone(comment) ; + + arr = (comment.reply_to_id == null) ? this.comments : this.commentsByDbId[comment.reply_to_id].replies ; + this._upd(arr, this.commentsByDbId, cloneComment) ; + + this._reorder() ; + + }, - // initializes this.comments - // commentId is the result of a computeFilterResults call : no assumption can be made on the order of ids (!) - // so we'll loop through allComments to carry order from allComments to comments - initComments : function(commentIds) { - this.comments = [] ; - for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { - - var index = CY.Array.indexOf(commentIds, this.allComments[i].id) ; - if (index != -1) { - - var cloneComment = CY.clone(this.allComments[i]) ; - - this.comments.push(cloneComment) ; - } - } - this._computeCommentsByDbId() ; - }, + // initializes this.comments + // commentId is the result of a computeFilterResults call : no assumption can be made on the order of ids (!) + // so we'll loop through allComments to carry order from allComments to comments + initComments : function(commentIds) { + this.comments = [] ; + for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { + + var index = CY.Array.indexOf(commentIds, this.allComments[i].id) ; + if (index != -1) { + + var cloneComment = CY.clone(this.allComments[i]) ; + + this.comments.push(cloneComment) ; + } + } + this._computeCommentsByDbId() ; + }, - _computeCommentsByDbId : function() { - this.commentsByDbId = {} ; - var flatComments = this.getThreads(this.comments) ; - for ( var i = 0; i < flatComments.length; i++) - this.commentsByDbId[flatComments[i].id] = flatComments[i]; - }, - - _computeAllCommentsByDbId : function() { - this.allCommentsByDbId = {} ; - var flatComments = this.getThreads(this.allComments) ; - for (var i = 0; i < flatComments.length; i++) - this.allCommentsByDbId[flatComments[i].id] = flatComments[i]; - }, - - // returns threads : - // given an array [comment1, comment2, comment3], this function will return [comment1, comment1reply1, comment1reply1reply1, comment1reply1reply2, comment2, comment3, comment3reply1] - //note : will return top parents ordered the way comments are - getThreads : function(comments) { - var ret = [] ; + _computeCommentsByDbId : function() { + this.commentsByDbId = {} ; + var flatComments = this.getThreads(this.comments) ; + for ( var i = 0; i < flatComments.length; i++) + this.commentsByDbId[flatComments[i].id] = flatComments[i]; + }, + + _computeAllCommentsByDbId : function() { + this.allCommentsByDbId = {} ; + var flatComments = this.getThreads(this.allComments) ; + for (var i = 0; i < flatComments.length; i++) + this.allCommentsByDbId[flatComments[i].id] = flatComments[i]; + }, + + // returns threads : + // given an array [comment1, comment2, comment3], this function will return [comment1, comment1reply1, comment1reply1reply1, comment1reply1reply2, comment2, comment3, comment3reply1] + //note : will return top parents ordered the way comments are + getThreads : function(comments) { + var ret = [] ; - for (var i = 0 ; i < comments.length ; i++) { - ret.push(comments[i]) ; - if (comments[i].replies.length > 0) - ret = ret.concat(this.getThreads(comments[i].replies)) ; - } - return ret ; - }, - _getPath : function(dic, comment) { - var ret = [comment] ; - - var c = comment ; - while (c.reply_to_id != null) { - c = dic[c.reply_to_id] ; - ret.push(c) ; - } - - return ret ; - }, - // returns comments as array : [comment, ..., comment's top parent] - getPath : function(comment) { - return this._getPath(this.commentsByDbId, comment) ; - }, - // getCommentFromIComment ... - getComment : function(dbId) { - return this.commentsByDbId[dbId] ; - }, - - getCommentByIdKey : function(id_key) { - for (var id in this.commentsByDbId) { - var comment = this.commentsByDbId[id] ; - if (comment.id_key == id_key) { - return comment ; - } - } - return null ; - }, - - isChild : function(commentDbId, parentDbId) { - var comment = this.commentsByDbId[commentDbId] ; - - var isChild = (commentDbId == parentDbId) ; - - while ((!isChild) && (comment.reply_to_id != null)) { - comment = this.commentsByDbId[comment.reply_to_id] ; - isChild = (comment.id == parentDbId) ; ; - } - return isChild ; - }, - - initToReadOnly : function(commentDbId, parentDbId) { - for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { - var comment = this.allComments[i] ; - for (var prop in comment) { - if (0 == prop.indexOf("can_") && typeof comment[prop] === 'boolean') - comment[prop] = false ; - } - } - }, - + for (var i = 0 ; i < comments.length ; i++) { + ret.push(comments[i]) ; + if (comments[i].replies.length > 0) + ret = ret.concat(this.getThreads(comments[i].replies)) ; + } + return ret ; + }, + _getPath : function(dic, comment) { + var ret = [comment] ; + + var c = comment ; + while (c.reply_to_id != null) { + c = dic[c.reply_to_id] ; + ret.push(c) ; + } + + return ret ; + }, + // returns comments as array : [comment, ..., comment's top parent] + getPath : function(comment) { + return this._getPath(this.commentsByDbId, comment) ; + }, + // getCommentFromIComment ... + getComment : function(dbId) { + return this.commentsByDbId[dbId] ; + }, + + getCommentByIdKey : function(id_key) { + for (var id in this.commentsByDbId) { + var comment = this.commentsByDbId[id] ; + if (comment.id_key == id_key) { + return comment ; + } + } + return null ; + }, + + isChild : function(commentDbId, parentDbId) { + var comment = this.commentsByDbId[commentDbId] ; + + var isChild = (commentDbId == parentDbId) ; + + while ((!isChild) && (comment.reply_to_id != null)) { + comment = this.commentsByDbId[comment.reply_to_id] ; + isChild = (comment.id == parentDbId) ; ; + } + return isChild ; + }, + + initToReadOnly : function(commentDbId, parentDbId) { + for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) { + var comment = this.allComments[i] ; + for (var prop in comment) { + if (0 == prop.indexOf("can_") && typeof comment[prop] === 'boolean') + comment[prop] = false ; + } + } + }, + ////////////////////////////// -// BROWSING FUNCTIONS +// BROWSING FUNCTIONS ////////////////////////////// - browsingIndex : function(dbId) { - var indx = {} ; - for (var order in this.ordered_comment_ids) { - var inFilter = CY.Array.filter(this.ordered_comment_ids[order], function(id) {return (id in this.commentsByDbId);}, this) ; - indx[order] = CY.Array.indexOf(inFilter, dbId ) ; - } - //indx['total'] = this.ordered_comment_ids['scope'].length - return indx ; - }, - - browse : function(order, whereto, dbId) { - //var arr = this.ordered_comment_ids[gConf['defaultBrowsingOrder']] ; -// CY.log(order) ; - var arr = this.ordered_comment_ids[order] ; - if (arr.length > 0) { - - var starti = -1 ; - if ((whereto == 'prev') || (whereto == 'next')) { - - for (var i = 0 ; i < arr.length ; i++) { - var id = arr[i] ; - if (id == dbId) { - starti = (whereto == 'prev') ? i - 1 : i + 1 ; - starti = (arr.length + starti) % arr.length ; // to guaranty a positive value - break ; - } - } - if (starti == -1) { - CY.error("internal error in db browse (was called with a dbId that isn't among the filtered ones)") ; - return null; - } - } - if (whereto == 'last') { - starti = arr.length - 1 ; - } - if (whereto == 'first') { - starti = 0 ; - } - - for (var i = starti, j = 0 ; (i >= 0) && (i < arr.length) ; j++ ) { - var id = arr[i] ; - if (id in this.commentsByDbId) // checking id is among the filtered ones - return this.commentsByDbId[id] ; - if ((whereto == 'prev') || (whereto == 'last')) - i = i - 1 ; - else - i = i + 1 ; - i = (arr.length + i) % arr.length ; // to guaranty a positive value - if (j > arr.length)// to prevent an infinite loop - break ; - } - - CY.error("internal error in db browse (could not find any filtered comment)") ; - } - return null; - }, - + browsingIndex : function(dbId) { + var indx = {} ; + for (var order in this.ordered_comment_ids) { + var inFilter = CY.Array.filter(this.ordered_comment_ids[order], function(id) {return (id in this.commentsByDbId);}, this) ; + indx[order] = CY.Array.indexOf(inFilter, dbId ) ; + } + //indx['total'] = this.ordered_comment_ids['scope'].length + return indx ; + }, + + browse : function(order, whereto, dbId) { + //var arr = this.ordered_comment_ids[gConf['defaultBrowsingOrder']] ; +// CY.log(order) ; + var arr = this.ordered_comment_ids[order] ; + if (arr.length > 0) { + + var starti = -1 ; + if ((whereto == 'prev') || (whereto == 'next')) { + + for (var i = 0 ; i < arr.length ; i++) { + var id = arr[i] ; + if (id == dbId) { + starti = (whereto == 'prev') ? i - 1 : i + 1 ; + starti = (arr.length + starti) % arr.length ; // to guaranty a positive value + break ; + } + } + if (starti == -1) { + CY.error("internal error in db browse (was called with a dbId that isn't among the filtered ones)") ; + return null; + } + } + if (whereto == 'last') { + starti = arr.length - 1 ; + } + if (whereto == 'first') { + starti = 0 ; + } + + for (var i = starti, j = 0 ; (i >= 0) && (i < arr.length) ; j++ ) { + var id = arr[i] ; + if (id in this.commentsByDbId) // checking id is among the filtered ones + return this.commentsByDbId[id] ; + if ((whereto == 'prev') || (whereto == 'last')) + i = i - 1 ; + else + i = i + 1 ; + i = (arr.length + i) % arr.length ; // to guaranty a positive value + if (j > arr.length)// to prevent an infinite loop + break ; + } + + CY.error("internal error in db browse (could not find any filtered comment)") ; + } + return null; + }, + ////////////////////////////// -// FILTER FUNCTIONS +// FILTER FUNCTIONS ////////////////////////////// - - //returns the list of commentIds satisfying the filter - computeFilterResults : function(filterGETValues) { - var filterData = {} ; - if (filterGETValues) { - for (key in filterGETValues) { - if (key.indexOf('filter_') == 0) - filterData[key.substr('filter_'.length)] = filterGETValues[key]; - } - } - else { - if (gLayout.isInFrame()) - filterData = parent.f_getFrameFilterData() ; - } + + //returns the list of commentIds satisfying the filter + computeFilterResults : function(filterGETValues) { + var filterData = {} ; + if (filterGETValues) { + for (key in filterGETValues) { + if (key.indexOf('filter_') == 0) + filterData[key.substr('filter_'.length)] = filterGETValues[key]; + } + } + else { + if (gLayout.isInFrame()) + filterData = parent.f_getFrameFilterData() ; + } - var cWithNameIds = [] ; - var rWithNameIds = [] ; - var filterName = "" ; - if ('name' in filterData) - filterName = filterData['name'] ; - this.filterByName(filterName, cWithNameIds, rWithNameIds) ; - - var cAfterDateIds = [] ; - var rAfterDateIds = [] ; - var filterDate = "" ; - if ('date' in filterData) - filterDate = filterData['date'] ; - this.filterByDate(filterDate, cAfterDateIds, rAfterDateIds) ; + var cWithNameIds = [] ; + var rWithNameIds = [] ; + var filterName = "" ; + if ('name' in filterData) + filterName = filterData['name'] ; + this.filterByName(filterName, cWithNameIds, rWithNameIds) ; + + var cAfterDateIds = [] ; + var rAfterDateIds = [] ; + var filterDate = "" ; + if ('date' in filterData) + filterDate = filterData['date'] ; + this.filterByDate(filterDate, cAfterDateIds, rAfterDateIds) ; - var cWithTextIds = [] ; - var rWithTextIds = [] ; - var filterText = "" ; - if ('text' in filterData) - filterText = filterData['text'] ; - this.filterByText(filterText, cWithTextIds, rWithTextIds) ; - - var cWithTagIds = [] ; - var rWithTagIds = [] ; - var filterTag = "" ; - if ('tag' in filterData) - filterTag = filterData['tag'] ; - this.filterByTag(filterTag, cWithTagIds, rWithTagIds) ; - - var cWithStateIds = [] ; - var rWithStateIds = [] ; - var filterState = "" ; - if ('state' in filterData) - filterState = filterData['state'] ; - this.filterByState(filterState, cWithStateIds, rWithStateIds) ; - - - var commentIds = [] ; - var replyIds = [] ; - // find intersections - for (var i = 0, ilen = cWithNameIds.length ; i < ilen ; i++) { - var id = cWithNameIds[i] ; - if ((CY.Array.indexOf(cAfterDateIds, id) != -1) && (CY.Array.indexOf(cWithTextIds,id) != -1) && (CY.Array.indexOf(cWithTagIds,id) != -1) && (CY.Array.indexOf(cWithStateIds,id) != -1)) { - commentIds.push(id) ; - } - } - - for (var i = 0, ilen = rWithNameIds.length ; i < ilen ; i++) { - var id = rWithNameIds[i] ; - if ((CY.Array.indexOf(rAfterDateIds,id) != -1) && (CY.Array.indexOf(rWithTextIds,id) != -1) && (CY.Array.indexOf(rWithTagIds,id) != -1) && (CY.Array.indexOf(rWithStateIds,id) != -1)) { - replyIds.push(id) ; - } - } - - var nbReplies = replyIds.length, nbComments = commentIds.length ; - var nbDiscussions = nbComments ; - - // look for comments to add because a reply satisfies the filter -// CY.log('replyIds:') ; -// CY.log(replyIds) ; -// CY.log('this.allCommentsByDbId :');CY.A -// CY.log(this.allCommentsByDbId); - for (var i = 0, ilen = replyIds.length ; i < ilen ; i++) { - var id = replyIds[i] ; - var reply = this.allCommentsByDbId[id] ; - var parents = this._getPath(this.allCommentsByDbId, reply) ; - var topComment = parents[parents.length - 1] ; - var id = topComment.id ; - if (CY.Array.indexOf(commentIds,id) == -1) { - commentIds.push(id) ; - nbDiscussions++ ; - } - } - - return {'commentIds': commentIds,'nbDiscussions':nbDiscussions, 'nbComments':nbComments, 'nbReplies':nbReplies} ; - }, + var cWithTextIds = [] ; + var rWithTextIds = [] ; + var filterText = "" ; + if ('text' in filterData) + filterText = filterData['text'] ; + this.filterByText(filterText, cWithTextIds, rWithTextIds) ; + + var cWithTagIds = [] ; + var rWithTagIds = [] ; + var filterTag = "" ; + if ('tag' in filterData) + filterTag = filterData['tag'] ; + this.filterByTag(filterTag, cWithTagIds, rWithTagIds) ; + + var cWithStateIds = [] ; + var rWithStateIds = [] ; + var filterState = "" ; + if ('state' in filterData) + filterState = filterData['state'] ; + this.filterByState(filterState, cWithStateIds, rWithStateIds) ; + + + var commentIds = [] ; + var replyIds = [] ; + // find intersections + for (var i = 0, ilen = cWithNameIds.length ; i < ilen ; i++) { + var id = cWithNameIds[i] ; + if ((CY.Array.indexOf(cAfterDateIds, id) != -1) && (CY.Array.indexOf(cWithTextIds,id) != -1) && (CY.Array.indexOf(cWithTagIds,id) != -1) && (CY.Array.indexOf(cWithStateIds,id) != -1)) { + commentIds.push(id) ; + } + } + + for (var i = 0, ilen = rWithNameIds.length ; i < ilen ; i++) { + var id = rWithNameIds[i] ; + if ((CY.Array.indexOf(rAfterDateIds,id) != -1) && (CY.Array.indexOf(rWithTextIds,id) != -1) && (CY.Array.indexOf(rWithTagIds,id) != -1) && (CY.Array.indexOf(rWithStateIds,id) != -1)) { + replyIds.push(id) ; + } + } + + var nbReplies = replyIds.length, nbComments = commentIds.length ; + var nbDiscussions = nbComments ; + + // look for comments to add because a reply satisfies the filter +// CY.log('replyIds:') ; +// CY.log(replyIds) ; +// CY.log('this.allCommentsByDbId :');CY.A +// CY.log(this.allCommentsByDbId); + for (var i = 0, ilen = replyIds.length ; i < ilen ; i++) { + var id = replyIds[i] ; + var reply = this.allCommentsByDbId[id] ; + var parents = this._getPath(this.allCommentsByDbId, reply) ; + var topComment = parents[parents.length - 1] ; + var id = topComment.id ; + if (CY.Array.indexOf(commentIds,id) == -1) { + commentIds.push(id) ; + nbDiscussions++ ; + } + } + + return {'commentIds': commentIds,'nbDiscussions':nbDiscussions, 'nbComments':nbComments, 'nbReplies':nbReplies} ; + }, - filterByText : function(text, cWithTextIds, rWithTextIds) { - var re = new RegExp(text, "gi"); - for (var id in this.allCommentsByDbId) { - var comment = this.allCommentsByDbId[id] ; - if (text == "" || re.exec(comment.title) != null || re.exec(comment.content) != null) { // search only in the comment (not the comment scope) for now - if (comment.reply_to_id == null) - cWithTextIds.push(comment.id); - else - rWithTextIds.push(comment.id) ; - } - } - }, + filterByText : function(text, cWithTextIds, rWithTextIds) { + var re = new RegExp(text, "gi"); + for (var id in this.allCommentsByDbId) { + var comment = this.allCommentsByDbId[id] ; + if (text == "" || re.exec(comment.title) != null || re.exec(comment.content) != null) { // search only in the comment (not the comment scope) for now + if (comment.reply_to_id == null) + cWithTextIds.push(comment.id); + else + rWithTextIds.push(comment.id) ; + } + } + }, - filterByName : function(name, cWithNameIds, rWithNameIds) { - for (var id in this.allCommentsByDbId) { - var comment = this.allCommentsByDbId[id] ; - if (name == "" || comment.name == name) { // sensitive exact match for now - if (comment.reply_to_id == null) - cWithNameIds.push(comment.id); - else - rWithNameIds.push(comment.id) ; - } - } - }, + filterByName : function(name, cWithNameIds, rWithNameIds) { + for (var id in this.allCommentsByDbId) { + var comment = this.allCommentsByDbId[id] ; + if (name == "" || comment.name == name) { // sensitive exact match for now + if (comment.reply_to_id == null) + cWithNameIds.push(comment.id); + else + rWithNameIds.push(comment.id) ; + } + } + }, - // warning : tags are case sensitive - filterByTag : function(tag, cWithTagIds, rWithTagIds) { - // cf ", ".join... in client.py - var re0 = new RegExp("^" + tag + "$", "g"); - var re1 = new RegExp("^" + tag + ", ", "g"); - var re2 = new RegExp(", " + tag + ", ", "g"); - var re3 = new RegExp(", " + tag + "$", "g"); - for (var id in this.allCommentsByDbId) { - var comment = this.allCommentsByDbId[id] ; - if (tag == "" || re0.exec(comment.tags) || re1.exec(comment.tags) != null || re2.exec(comment.tags) != null || re3.exec(comment.tags) != null) { // search only in the comment (not the comment scope) for now - if (comment.reply_to_id == null) - cWithTagIds.push(comment.id); - else - rWithTagIds.push(comment.id) ; - } - } - }, + // warning : tags are case sensitive + filterByTag : function(tag, cWithTagIds, rWithTagIds) { + // cf ", ".join... in client.py + var re0 = new RegExp("^" + tag + "$", "g"); + var re1 = new RegExp("^" + tag + ", ", "g"); + var re2 = new RegExp(", " + tag + ", ", "g"); + var re3 = new RegExp(", " + tag + "$", "g"); + for (var id in this.allCommentsByDbId) { + var comment = this.allCommentsByDbId[id] ; + if (tag == "" || re0.exec(comment.tags) || re1.exec(comment.tags) != null || re2.exec(comment.tags) != null || re3.exec(comment.tags) != null) { // search only in the comment (not the comment scope) for now + if (comment.reply_to_id == null) + cWithTagIds.push(comment.id); + else + rWithTagIds.push(comment.id) ; + } + } + }, - filterByState : function(state, cWithStateIds, rWithStateIds) { - for (var id in this.allCommentsByDbId) { - var comment = this.allCommentsByDbId[id] ; - if (state == "" || comment.state == state) { - if (comment.reply_to_id == null) - cWithStateIds.push(comment.id); - else - rWithStateIds.push(comment.id) ; - } - } - }, + filterByState : function(state, cWithStateIds, rWithStateIds) { + for (var id in this.allCommentsByDbId) { + var comment = this.allCommentsByDbId[id] ; + if (state == "" || comment.state == state) { + if (comment.reply_to_id == null) + cWithStateIds.push(comment.id); + else + rWithStateIds.push(comment.id) ; + } + } + }, - filterByDate : function(date_str, cAfterDateIds, rAfterDateIds) { - var date = (date_str == "") ? 0 : parseInt(date_str) ; - for (var id in this.allCommentsByDbId) { - var comment = this.allCommentsByDbId[id] ; - if (comment.modified > date) { - if (comment.reply_to_id == null) - cAfterDateIds.push(comment.id); - else - rAfterDateIds.push(comment.id) ; - } - } - }, -// filterByDate : function(date_str, cAfterDateIds, rAfterDateIds) { -// var date = (date_str == "") ? "" : Date.parseDate(date_str, sv_client_date_fmt).getTime() ; -// for (var id in this.allCommentsByDbId) { -// var comment = this.allCommentsByDbId[id] ; -// // TODO : created should be the date not a string !! -// var create_date = (date_str == "") ? "" : Date.parseDate(comment.created_str, sv_client_date_fmt).getTime() ; -// if (date_str == "" || create_date > date) { -// if (comment.reply_to_id == null) -// cAfterDateIds.push(comment.id); -// else -// rAfterDateIds.push(comment.id) ; -// } -// } -// }, - + filterByDate : function(date_str, cAfterDateIds, rAfterDateIds) { + var date = (date_str == "") ? 0 : parseInt(date_str) ; + for (var id in this.allCommentsByDbId) { + var comment = this.allCommentsByDbId[id] ; + if (comment.modified > date) { + if (comment.reply_to_id == null) + cAfterDateIds.push(comment.id); + else + rAfterDateIds.push(comment.id) ; + } + } + }, +// filterByDate : function(date_str, cAfterDateIds, rAfterDateIds) { +// var date = (date_str == "") ? "" : Date.parseDate(date_str, sv_client_date_fmt).getTime() ; +// for (var id in this.allCommentsByDbId) { +// var comment = this.allCommentsByDbId[id] ; +// // TODO : created should be the date not a string !! +// var create_date = (date_str == "") ? "" : Date.parseDate(comment.created_str, sv_client_date_fmt).getTime() ; +// if (date_str == "" || create_date > date) { +// if (comment.reply_to_id == null) +// cAfterDateIds.push(comment.id); +// else +// rAfterDateIds.push(comment.id) ; +// } +// } +// }, + ////////////////////////////// -// COUNT FUNCTIONS +// COUNT FUNCTIONS ////////////////////////////// - - getCommentsAndRepliesCounts : function(all) { - var cCount = 0 ; - var rCount = 0 ; - var arr = (all) ? this.allComments:this.comments; - var flatComments = this.getThreads(arr) ; - for ( var i = 0; i < flatComments.length; i++) { - if (flatComments[i].reply_to_id == null) - cCount++ ; - else - rCount++ ; - } - return [cCount, rCount] ; - }, + + getCommentsAndRepliesCounts : function(all) { + var cCount = 0 ; + var rCount = 0 ; + var arr = (all) ? this.allComments:this.comments; + var flatComments = this.getThreads(arr) ; + for ( var i = 0; i < flatComments.length; i++) { + if (flatComments[i].reply_to_id == null) + cCount++ ; + else + rCount++ ; + } + return [cCount, rCount] ; + }, - // counts both comments and comments - getCommentsNb : function(all) { - var arr = (all) ? this.allComments:this.comments; - return this.getThreads(arr).length ; - }, - getFilteredCommentIdsAsString : function() { - var ret = "" ; - for (var id in this.commentsByDbId) - ret = ret + id + "," ; - return ret ; - } + // counts both comments and comments + getCommentsNb : function(all) { + var arr = (all) ? this.allComments:this.comments; + return this.getThreads(arr).length ; + }, + getFilteredCommentIdsAsString : function() { + var ret = "" ; + for (var id in this.commentsByDbId) + ret = ret + id + "," ; + return ret ; + } } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_dlg_intercept.js --- a/src/cm/media/js/client/c_dlg_intercept.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_dlg_intercept.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,60 +1,60 @@ // dialog related _afterDlg = function(args) { - var yesFunction = args[0] ; - var yesFunctionContext = args[1] ; - var yesFunctionArgs = args[2] ; - yesFunction.call(yesFunctionContext, yesFunctionArgs) ; + var yesFunction = args[0] ; + var yesFunctionContext = args[1] ; + var yesFunctionArgs = args[2] ; + yesFunction.call(yesFunctionContext, yesFunctionArgs) ; } _abortNewCommentConfirmed = function(args) { - if (isICommentFormVisible()) { - if (gLayout.isInFrame()) { - gSync.hideICommentForm({fn:function(){_afterDlg(args) ;}}) ; - gSync.resume() ; - } - } + if (isICommentFormVisible()) { + if (gLayout.isInFrame()) { + gSync.hideICommentForm({fn:function(){_afterDlg(args) ;}}) ; + gSync.resume() ; + } + } } _abortNewReplyConfirmed = function(args) { - if (gNewReplyHost != null) { - if (gLayout.isInFrame()) { - cancelNewReplyForm() ; - _afterDlg(args) ; - } - } + if (gNewReplyHost != null) { + if (gLayout.isInFrame()) { + cancelNewReplyForm() ; + _afterDlg(args) ; + } + } } _abortNewEditConfirmed = function(args) { - if (gEditICommentHost != null) { - if (gLayout.isInFrame()) { - cancelEditForm() ; - _afterDlg(args) ; - } - } + if (gEditICommentHost != null) { + if (gLayout.isInFrame()) { + cancelEditForm() ; + _afterDlg(args) ; + } + } } //if topIComment != null will check if edit or new reply is hosted by a child of topIComment //if topIComment == null will check if edit or a new reply is hosted somewhere checkForOpenedDialog = function(topIComment, yesFunction, yesFunctionContext, yesFunctionArgs) { - var childrenIds = [] ; - if (topIComment != null) { - childrenIds = CY.Array.map(gDb.getThreads([gDb.getComment(topIComment.commentId)]), function(comment) { return comment.id ;}) ; - } - - if (isICommentFormVisible() - || - (gNewReplyHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gNewReplyHost.commentId) != -1)) - || - (gEditICommentHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gEditICommentHost.commentId) != -1))) { - if (gLayout.isInFrame()) { - if (isICommentFormVisible()) - parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewCommentConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; - else if (gNewReplyHost != null) - parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewReplyConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; - else if (gEditICommentHost != null) - parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewEditConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; - } - } - else { - yesFunction.call(yesFunctionContext, []) ; - } + var childrenIds = [] ; + if (topIComment != null) { + childrenIds = CY.Array.map(gDb.getThreads([gDb.getComment(topIComment.commentId)]), function(comment) { return comment.id ;}) ; + } + + if (isICommentFormVisible() + || + (gNewReplyHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gNewReplyHost.commentId) != -1)) + || + (gEditICommentHost != null && (topIComment == null || CY.Array.indexOf(childrenIds, gEditICommentHost.commentId) != -1))) { + if (gLayout.isInFrame()) { + if (isICommentFormVisible()) + parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewCommentConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; + else if (gNewReplyHost != null) + parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewReplyConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; + else if (gEditICommentHost != null) + parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"), gettext("Warning"), null, null, null, _abortNewEditConfirmed, this, [yesFunction, yesFunctionContext, yesFunctionArgs]) ; + } + } + else { + yesFunction.call(yesFunctionContext, []) ; + } } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_edit_form.js --- a/src/cm/media/js/client/c_edit_form.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_edit_form.js Tue Nov 30 09:53:35 2010 +0100 @@ -3,131 +3,131 @@ dbgc = null ; showEditForm = function(iCommentHost) { - - if (gEdit == null) { - gEdit = { - 'ids':{ - 'formId':CY.guid(), - 'formTitleId':CY.guid(), - 'nameInputId':CY.guid(), - 'emailInputId':CY.guid(), - 'titleInputId':CY.guid(), - 'contentInputId':CY.guid(), - 'tagsInputId':CY.guid(), - 'formatInputId':CY.guid(), - 'startWrapperInputId':CY.guid(), - 'endWrapperInputId':CY.guid(), - 'startOffsetInputId':CY.guid(), - 'endOffsetInputId':CY.guid(), - 'changeScopeInputId':CY.guid(), - 'changeScopeInputWrapper':CY.guid(), - 'selectionPlaceId':CY.guid(), - 'keyId':CY.guid(), - 'editCommentId':CY.guid(), - 'currentSelId':CY.guid(), - 'currentSelIdI':CY.guid(), - 'addBtnId':CY.guid(), - 'cancelBtnId':CY.guid() - }, - 'handlers':{} - } ; - } - - gEditICommentHost = iCommentHost ; + + if (gEdit == null) { + gEdit = { + 'ids':{ + 'formId':CY.guid(), + 'formTitleId':CY.guid(), + 'nameInputId':CY.guid(), + 'emailInputId':CY.guid(), + 'titleInputId':CY.guid(), + 'contentInputId':CY.guid(), + 'tagsInputId':CY.guid(), + 'formatInputId':CY.guid(), + 'startWrapperInputId':CY.guid(), + 'endWrapperInputId':CY.guid(), + 'startOffsetInputId':CY.guid(), + 'endOffsetInputId':CY.guid(), + 'changeScopeInputId':CY.guid(), + 'changeScopeInputWrapper':CY.guid(), + 'selectionPlaceId':CY.guid(), + 'keyId':CY.guid(), + 'editCommentId':CY.guid(), + 'currentSelId':CY.guid(), + 'currentSelIdI':CY.guid(), + 'addBtnId':CY.guid(), + 'cancelBtnId':CY.guid() + }, + 'handlers':{} + } ; + } + + gEditICommentHost = iCommentHost ; - gEditICommentHost.hideContent() ; + gEditICommentHost.hideContent() ; -// FORM HTML - var overlayHtml = getHtml(gEdit['ids']) ; - var editHeader = '
' + overlayHtml['headerContent'] + '
' ; - var editBody = '
' + overlayHtml['bodyContent'] + '
' ; - -// cf. http://yuilibrary.com/projects/yui3/ticket/2528319 - gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(editHeader),CY.WidgetStdMod.AFTER); - gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(editBody),CY.WidgetStdMod.AFTER); - -// FORM TITLE - CY.get("#"+gEdit['ids']['formTitleId']).set('innerHTML', gettext("Edit comment")) ; +// FORM HTML + var overlayHtml = getHtml(gEdit['ids']) ; + var editHeader = '
' + overlayHtml['headerContent'] + '
' ; + var editBody = '
' + overlayHtml['bodyContent'] + '
' ; + +// cf. http://yuilibrary.com/projects/yui3/ticket/2528319 + gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(editHeader),CY.WidgetStdMod.AFTER); + gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(editBody),CY.WidgetStdMod.AFTER); + +// FORM TITLE + CY.get("#"+gEdit['ids']['formTitleId']).set('innerHTML', gettext("Edit comment")) ; // FETCH FORM VALUES FROM COMMENT - - var comment = gDb.getComment(gEditICommentHost.commentId) ; - CY.get("#"+gEdit['ids']['editCommentId']).set('value', comment.id) ; - CY.get("#"+gEdit['ids']['keyId']).set('value', comment.key) ; + + var comment = gDb.getComment(gEditICommentHost.commentId) ; + CY.get("#"+gEdit['ids']['editCommentId']).set('value', comment.id) ; + CY.get("#"+gEdit['ids']['keyId']).set('value', comment.key) ; - CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").set('checked', false) ; - if (comment.reply_to_id != null) - CY.get("#"+gEdit['ids']['changeScopeInputId']).addClass('displaynone') - changeScopeFormClick() ; // to adapt + CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").set('checked', false) ; + if (comment.reply_to_id != null) + CY.get("#"+gEdit['ids']['changeScopeInputId']).addClass('displaynone') + changeScopeFormClick() ; // to adapt - CY.get("#"+gEdit['ids']['nameInputId']).set('value', comment.name) ; - CY.get("#"+gEdit['ids']['emailInputId']).set('value', comment.email) ; + CY.get("#"+gEdit['ids']['nameInputId']).set('value', comment.name) ; + CY.get("#"+gEdit['ids']['emailInputId']).set('value', comment.email) ; - if (comment.logged_author) { - CY.get("#"+gEdit['ids']['nameInputId']).setAttribute("disabled", true); - CY.get("#"+gEdit['ids']['emailInputId']).setAttribute("disabled", true); - } - + if (comment.logged_author) { + CY.get("#"+gEdit['ids']['nameInputId']).setAttribute("disabled", true); + CY.get("#"+gEdit['ids']['emailInputId']).setAttribute("disabled", true); + } + // FORM VALUES - CY.get("#"+gEdit['ids']['titleInputId']).set('value', comment['title']) ; - CY.get("#"+gEdit['ids']['contentInputId']).set('value', comment['content']) ; - CY.get("#"+gEdit['ids']['tagsInputId']).set('value', comment['tags']) ; - - CY.get("#"+gEdit['ids']['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ... - -// WIDTH - var width = gLayout.getTopICommentsWidth() ; - changeFormFieldsWidth(gEdit['ids']['formId'], width) ; - + CY.get("#"+gEdit['ids']['titleInputId']).set('value', comment['title']) ; + CY.get("#"+gEdit['ids']['contentInputId']).set('value', comment['content']) ; + CY.get("#"+gEdit['ids']['tagsInputId']).set('value', comment['tags']) ; + + CY.get("#"+gEdit['ids']['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ... + +// WIDTH + var width = gLayout.getTopICommentsWidth() ; + changeFormFieldsWidth(gEdit['ids']['formId'], width) ; + // ATTACH EVENT HANDLERS - gEdit['handlers']['addBtnId'] = CY.on("click", onEditSaveClick, "#"+gEdit['ids']['addBtnId']); - gEdit['handlers']['cancelBtnId'] = CY.on("click", onEditCancelClick, "#"+gEdit['ids']['cancelBtnId']); - gEdit['handlers']['changeScope'] = CY.on("click", onChangeScopeClick, "#"+gEdit['ids']['changeScopeInputId']); - + gEdit['handlers']['addBtnId'] = CY.on("click", onEditSaveClick, "#"+gEdit['ids']['addBtnId']); + gEdit['handlers']['cancelBtnId'] = CY.on("click", onEditCancelClick, "#"+gEdit['ids']['cancelBtnId']); + gEdit['handlers']['changeScope'] = CY.on("click", onChangeScopeClick, "#"+gEdit['ids']['changeScopeInputId']); + } onEditSaveClick = function(iCommentHost) { - if (readyForAction()) - gSync.editComment() ; + if (readyForAction()) + gSync.editComment() ; } onEditCancelClick = function(iCommentHost) { - if (readyForAction()) - gSync.cancelEdit() ; + if (readyForAction()) + gSync.cancelEdit() ; } onChangeScopeClick = function() { - if (readyForAction()) - gSync.changeScopeFormClick() ; - else {// (onChangeScopeClick triggers an animation : checking for readyForAction does not prevent the checkbox change ...) - var chckCtrl = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input") ; - var chck = chckCtrl.get('checked') ; - chckCtrl.set('checked', !chck) ; // set it back - } + if (readyForAction()) + gSync.changeScopeFormClick() ; + else {// (onChangeScopeClick triggers an animation : checking for readyForAction does not prevent the checkbox change ...) + var chckCtrl = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input") ; + var chck = chckCtrl.get('checked') ; + chckCtrl.set('checked', !chck) ; // set it back + } } changeScopeFormClick = function() { - var node = CY.get("#"+gEdit['ids']['currentSelId']) ; - if (CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked')) - node.removeClass('displaynone') ; - else - node.addClass('displaynone') ; + var node = CY.get("#"+gEdit['ids']['currentSelId']) ; + if (CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked')) + node.removeClass('displaynone') ; + else + node.addClass('displaynone') ; } cancelEditForm = function() { - if (gEditICommentHost != null) { + if (gEditICommentHost != null) { // DETACH EVENT HANDLERS - for (var id in gEdit['handlers']) { - if (gEdit['handlers'][id] != null) { - gEdit['handlers'][id].detach() ; - gEdit['handlers'][id] = null ; - } - } + for (var id in gEdit['handlers']) { + if (gEdit['handlers'][id] != null) { + gEdit['handlers'][id].detach() ; + gEdit['handlers'][id] = null ; + } + } // REMOVE EDIT FORM NODES FROM ICOMMENT OVERLAY - var node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-body") ; - node.get('parentNode').removeChild(node) ; - node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-header") ; - node.get('parentNode').removeChild(node) ; + var node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-body") ; + node.get('parentNode').removeChild(node) ; + node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-header") ; + node.get('parentNode').removeChild(node) ; // SHOW ICOMMENT OVERLAY - gEditICommentHost.showContent() ; - - gEditICommentHost = null ; - } + gEditICommentHost.showContent() ; + + gEditICommentHost = null ; + } } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_icomment.js --- a/src/cm/media/js/client/c_icomment.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_icomment.js Tue Nov 30 09:53:35 2010 +0100 @@ -3,478 +3,478 @@ // IComment == IHM comment class IComment = function() { - - this.commentId = null ; - - var iCommentWidth = gLayout.getTopICommentsWidth() ; - var iCommentLeft = gConf['iCommentLeftPadding'] ; - - var changeToPending = gettext("change comment state to pending") ; - var changeToApprove = gettext("change comment state to approved") ; - var changeToUnapprove= gettext("change comment state to unapproved") ; - var cancelChange = gettext("cancel changing the state of this comment") ; - var pending = gettext("pending") ; - var approved = gettext("approved") ; - var unapproved = gettext("unapproved") ; - var cancel = gettext("cancel") ; - var showReplies = gettext("show replies") ; - var changeTo= gettext("change to:") ; - var reply = ngettext("reply","replies",1) ; // hack to get django to add 'replies' as the plural in f_text_view_frame !! - var editComment = gettext("edit comment") ; - var deleteComment = gettext("delete comment") ; - var edit = gettext("edit") ; - var del = gettext("delete") ; - var close = gettext("close") ; - var showScope = gettext("show scope") ; - var scopeRemoved = gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.") ; - - // no header, no body yet - this.overlay = new CY.Overlay( { - zIndex :3, - shim :false, /* until we really need it, no shim */ - visible :false, - width : iCommentWidth, - xy : [ iCommentLeft, 0 ], - headerContent : '
' + - '
' + - ''+ "vis" +'' + " " + - '' + edit + '' + " " + - '' + del + '' + " " + - '
' + - '
' + - changeTo + ' ' + - ''+ pending +'' + " " + - ''+ approved +'' + " " + - ''+ unapproved +'' + " " + - '' + cancel +'' + " " + - '
' + - '
' + - scopeRemoved + - '
' + - '-' + - 'X' + - '
', - bodyContent : '
' + - '' + - '' + - '' + showReplies +'' + " " + - '' + reply +'' + " " + - '' + - '
' - }); - - this.overlay.get('contentBox').addClass("c-comment") ; - - // attach to DOM - this.overlay.render('#leftcolumn'); - - this.animation = new CY.Anim({ + + this.commentId = null ; + + var iCommentWidth = gLayout.getTopICommentsWidth() ; + var iCommentLeft = gConf['iCommentLeftPadding'] ; + + var changeToPending = gettext("change comment state to pending") ; + var changeToApprove = gettext("change comment state to approved") ; + var changeToUnapprove= gettext("change comment state to unapproved") ; + var cancelChange = gettext("cancel changing the state of this comment") ; + var pending = gettext("pending") ; + var approved = gettext("approved") ; + var unapproved = gettext("unapproved") ; + var cancel = gettext("cancel") ; + var showReplies = gettext("show replies") ; + var changeTo= gettext("change to:") ; + var reply = ngettext("reply","replies",1) ; // hack to get django to add 'replies' as the plural in f_text_view_frame !! + var editComment = gettext("edit comment") ; + var deleteComment = gettext("delete comment") ; + var edit = gettext("edit") ; + var del = gettext("delete") ; + var close = gettext("close") ; + var showScope = gettext("show scope") ; + var scopeRemoved = gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.") ; + + // no header, no body yet + this.overlay = new CY.Overlay( { + zIndex :3, + shim :false, /* until we really need it, no shim */ + visible :false, + width : iCommentWidth, + xy : [ iCommentLeft, 0 ], + headerContent : '
' + + '
' + + ''+ "vis" +'' + " " + + '' + edit + '' + " " + + '' + del + '' + " " + + '
' + + '
' + + changeTo + ' ' + + ''+ pending +'' + " " + + ''+ approved +'' + " " + + ''+ unapproved +'' + " " + + '' + cancel +'' + " " + + '
' + + '
' + + scopeRemoved + + '
' + + '-' + + 'X' + + '
', + bodyContent : '
' + + '' + + '' + + '' + showReplies +'' + " " + + '' + reply +'' + " " + + '' + + '
' + }); + + this.overlay.get('contentBox').addClass("c-comment") ; + + // attach to DOM + this.overlay.render('#leftcolumn'); + + this.animation = new CY.Anim({ node: this.overlay.get('boundingBox'), duration: gPrefs.get('general','animduration'), easing: CY.Easing.easeOut - }); + }); - // CY.on won't work - this.overlay.get('contentBox').query(".c-close").on("click", this.onCloseCommentClick, this); - this.overlay.get('contentBox').query(".c-moderate").on("click", this.onModerateCommentClick, this); - this.overlay.get('contentBox').query(".c-state-pending").on("click", this.onPendingCommentClick, this); - this.overlay.get('contentBox').query(".c-state-approved").on("click", this.onApprovedCommentClick, this); - this.overlay.get('contentBox').query(".c-state-unapproved").on("click", this.onUnapprovedCommentClick, this); - this.overlay.get('contentBox').query(".c-state-cancel").on("click", this.onCancelStateChangeClick, this); - this.overlay.get('contentBox').query(".c-edit").on("click", this.onEditCommentClick, this); - this.overlay.get('contentBox').query(".c-delete").on("click", this.onDeleteCommentClick, this); - this.overlay.get('contentBox').query(".c-reply").on("click", this.onReplyCommentClick, this); - this.overlay.get('contentBox').query(".c-readreplies").on("click", this.onReadRepliesCommentClick, this); + // CY.on won't work + this.overlay.get('contentBox').query(".c-close").on("click", this.onCloseCommentClick, this); + this.overlay.get('contentBox').query(".c-moderate").on("click", this.onModerateCommentClick, this); + this.overlay.get('contentBox').query(".c-state-pending").on("click", this.onPendingCommentClick, this); + this.overlay.get('contentBox').query(".c-state-approved").on("click", this.onApprovedCommentClick, this); + this.overlay.get('contentBox').query(".c-state-unapproved").on("click", this.onUnapprovedCommentClick, this); + this.overlay.get('contentBox').query(".c-state-cancel").on("click", this.onCancelStateChangeClick, this); + this.overlay.get('contentBox').query(".c-edit").on("click", this.onEditCommentClick, this); + this.overlay.get('contentBox').query(".c-delete").on("click", this.onDeleteCommentClick, this); + this.overlay.get('contentBox').query(".c-reply").on("click", this.onReplyCommentClick, this); + this.overlay.get('contentBox').query(".c-readreplies").on("click", this.onReadRepliesCommentClick, this); - this.overlay.get('contentBox').query(".icomment-header").on("mouseenter", this.onMouseEnterHeader, this); - this.overlay.get('contentBox').query(".icomment-header").on("mouseleave", this.onMouseLeaveHeader, this); - - this.overlay.get('contentBox').on("click", this.onCommentClick, this); + this.overlay.get('contentBox').query(".icomment-header").on("mouseenter", this.onMouseEnterHeader, this); + this.overlay.get('contentBox').query(".icomment-header").on("mouseleave", this.onMouseLeaveHeader, this); + + this.overlay.get('contentBox').on("click", this.onCommentClick, this); } IComment.prototype = { - // checking readyForAction is not enough because handler could be called after animation end in the case : - // close btn is clicked before animation end (so before overlay gets hidden) but handler is called after so preventClickOn is false and close is called on an invisible overlay. - // (whan clicking very fast on the close button while close animation is taking place). - // SO : SHOULD ALWAYS CHECK FOR VISIBLE OVERLAY IN HANDLERS THAT COULD BE CALLED FROM AN ANIMATED OVERLAY - onCloseCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) - gSync.closeComment(this) ; - }, - onModerateCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - this.overlay.get('contentBox').query(".c-iactions").addClass("displaynone") ; - this.overlay.get('contentBox').query(".c-state-actions").removeClass("displaynone") ; - } - }, - onPendingCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - gSync.moderateComment(this, 'pending') ; - } - }, - onApprovedCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - gSync.moderateComment(this, 'approved') ; - } - }, - onUnapprovedCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - gSync.moderateComment(this, 'unapproved') ; - } - }, - onCancelStateChangeClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; - this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; - } - }, - onDeleteCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) { - gSync.removeComment(this) ; - } - }, - onEditCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) - gSync.showEditForm(this) ; - }, - onReplyCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) - gSync.showReplyForm(this) ; - }, - onReadRepliesCommentClick : function (e) { - e.halt() ; // prevent click triggered on content box - if (readyForAction() && this.isVisible()) - gSync.openComment(this) ; - }, - onCommentClick : function (e) { - if (readyForAction() && this.isVisible()) { - // first condition here is checking it's not clicked via a 'show comments' link - if (e.target.get("target") == "_blank") { - var link = e.target ; - var showCommentUrl = sv_site_url + sv_text_view_show_comment_url ; - if (link.get('href').indexOf(showCommentUrl) == 0) { - var res = (new RegExp('comment_id_key=([^&]*)', "g")).exec(link.get('href')) ; - if (res != null) { - // open new comment .... we'll suppose it satisfies the filter for now - // TODO : should we reset the filter in this case ? instead of having the link open in a new window - var id_key = res[1] ; - var comment = gDb.getCommentByIdKey(id_key) ; - if (comment != null) { - e.halt() ; - if (!link.hasClass("c-permalink")) {// clicking on the permalink itself should do anything - checkForOpenedDialog(null, function() { - gSync.showSingleComment(comment) ; - }) ; - } - } - } - } - } - else { - if (gShowingAllComments) { - // next special dirty case test explained : when editing/replying to a comment with gShowingAllComments a click in the edit/reply form also is a click on the iComment, in this case we don't want to showSingleComment .... - // should be handled via a preventDefault in some way - if (!this._isHostingAForm()) { - var comment = gDb.getComment(this.commentId) ; - checkForOpenedDialog(null, function() { - if (comment != null) - gSync.showSingleComment(comment) ; - }) - } - } - else - gSync.activate(this) ; - } - } - }, - - onMouseEnterHeader : function () { - if (readyForAction() && this.isVisible() && (sv_prefix=="")) { - this.overlay.get('contentBox').query(".c-permalink").removeClass('displaynone'); - } - }, - - onMouseLeaveHeader : function () { - if (readyForAction() && this.isVisible() && (sv_prefix=="")) { - this.overlay.get('contentBox').query(".c-permalink").addClass('displaynone'); - } - }, - - setWidth : function(width) { - this.overlay.get('boundingBox').setStyle("width", width + 'px'); - }, - - activate:function() { - // debug !! -// CY.log('activate' + this.commentId) ; - this.overlay.get('boundingBox').addClass('c-focus-comment') ; - - }, - - deactivate:function() { - // debug !! -// CY.log('deactivate' + this.commentId) ; - this.overlay.get('boundingBox').removeClass('c-focus-comment') ; - - }, - hide:function() { - // is IComment the top active one ? - if (gIComments.isTopActive(this.commentId)) { // then try to activate next in displayed list - if (!gIComments.activateVisibleNext()) - gIComments.deactivate() ; - } + // checking readyForAction is not enough because handler could be called after animation end in the case : + // close btn is clicked before animation end (so before overlay gets hidden) but handler is called after so preventClickOn is false and close is called on an invisible overlay. + // (whan clicking very fast on the close button while close animation is taking place). + // SO : SHOULD ALWAYS CHECK FOR VISIBLE OVERLAY IN HANDLERS THAT COULD BE CALLED FROM AN ANIMATED OVERLAY + onCloseCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) + gSync.closeComment(this) ; + }, + onModerateCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + this.overlay.get('contentBox').query(".c-iactions").addClass("displaynone") ; + this.overlay.get('contentBox').query(".c-state-actions").removeClass("displaynone") ; + } + }, + onPendingCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + gSync.moderateComment(this, 'pending') ; + } + }, + onApprovedCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + gSync.moderateComment(this, 'approved') ; + } + }, + onUnapprovedCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + gSync.moderateComment(this, 'unapproved') ; + } + }, + onCancelStateChangeClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; + this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; + } + }, + onDeleteCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) { + gSync.removeComment(this) ; + } + }, + onEditCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) + gSync.showEditForm(this) ; + }, + onReplyCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) + gSync.showReplyForm(this) ; + }, + onReadRepliesCommentClick : function (e) { + e.halt() ; // prevent click triggered on content box + if (readyForAction() && this.isVisible()) + gSync.openComment(this) ; + }, + onCommentClick : function (e) { + if (readyForAction() && this.isVisible()) { + // first condition here is checking it's not clicked via a 'show comments' link + if (e.target.get("target") == "_blank") { + var link = e.target ; + var showCommentUrl = sv_site_url + sv_text_view_show_comment_url ; + if (link.get('href').indexOf(showCommentUrl) == 0) { + var res = (new RegExp('comment_id_key=([^&]*)', "g")).exec(link.get('href')) ; + if (res != null) { + // open new comment .... we'll suppose it satisfies the filter for now + // TODO : should we reset the filter in this case ? instead of having the link open in a new window + var id_key = res[1] ; + var comment = gDb.getCommentByIdKey(id_key) ; + if (comment != null) { + e.halt() ; + if (!link.hasClass("c-permalink")) {// clicking on the permalink itself should do anything + checkForOpenedDialog(null, function() { + gSync.showSingleComment(comment) ; + }) ; + } + } + } + } + } + else { + if (gShowingAllComments) { + // next special dirty case test explained : when editing/replying to a comment with gShowingAllComments a click in the edit/reply form also is a click on the iComment, in this case we don't want to showSingleComment .... + // should be handled via a preventDefault in some way + if (!this._isHostingAForm()) { + var comment = gDb.getComment(this.commentId) ; + checkForOpenedDialog(null, function() { + if (comment != null) + gSync.showSingleComment(comment) ; + }) + } + } + else + gSync.activate(this) ; + } + } + }, + + onMouseEnterHeader : function () { + if (readyForAction() && this.isVisible() && (sv_prefix=="")) { + this.overlay.get('contentBox').query(".c-permalink").removeClass('displaynone'); + } + }, + + onMouseLeaveHeader : function () { + if (readyForAction() && this.isVisible() && (sv_prefix=="")) { + this.overlay.get('contentBox').query(".c-permalink").addClass('displaynone'); + } + }, + + setWidth : function(width) { + this.overlay.get('boundingBox').setStyle("width", width + 'px'); + }, + + activate:function() { + // debug !! +// CY.log('activate' + this.commentId) ; + this.overlay.get('boundingBox').addClass('c-focus-comment') ; + + }, + + deactivate:function() { + // debug !! +// CY.log('deactivate' + this.commentId) ; + this.overlay.get('boundingBox').removeClass('c-focus-comment') ; + + }, + hide:function() { + // is IComment the top active one ? + if (gIComments.isTopActive(this.commentId)) { // then try to activate next in displayed list + if (!gIComments.activateVisibleNext()) + gIComments.deactivate() ; + } - if (this.isVisible()) { - this.overlay.hide(); - this.overlay.blur() ; - } - }, - hideContent:function() { - this.overlay.get('contentBox').query(".icomment-header").addClass('displaynone') ; - this.overlay.get('contentBox').query(".icomment-body").addClass('displaynone') ; - }, - showContent:function() { - this.overlay.get('contentBox').query(".icomment-header").removeClass('displaynone') ; - this.overlay.get('contentBox').query(".icomment-body").removeClass('displaynone') ; - }, - isVisible:function() { - return this.overlay.get('visible') ; - }, - show:function() { - this.hideReadRepliesLnk() ; // for now - return this.overlay.show() ; - }, - showReadRepliesLnk:function() { - this.overlay.get('contentBox').query(".c-readreplies").removeClass('displaynone') ; - }, - hideReadRepliesLnk:function() { - this.overlay.get('contentBox').query(".c-readreplies").addClass('displaynone') ; - }, - changeModeration:function(comment) { - var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; - moderationLnk.set("innerHTML", gettext(comment.state)) ; - - moderationLnk.removeClass("c-state-approved") ; - moderationLnk.removeClass("c-state-pending") ; - moderationLnk.removeClass("c-state-unapproved") ; - moderationLnk.addClass("c-state-" + comment.state) ; + if (this.isVisible()) { + this.overlay.hide(); + this.overlay.blur() ; + } + }, + hideContent:function() { + this.overlay.get('contentBox').query(".icomment-header").addClass('displaynone') ; + this.overlay.get('contentBox').query(".icomment-body").addClass('displaynone') ; + }, + showContent:function() { + this.overlay.get('contentBox').query(".icomment-header").removeClass('displaynone') ; + this.overlay.get('contentBox').query(".icomment-body").removeClass('displaynone') ; + }, + isVisible:function() { + return this.overlay.get('visible') ; + }, + show:function() { + this.hideReadRepliesLnk() ; // for now + return this.overlay.show() ; + }, + showReadRepliesLnk:function() { + this.overlay.get('contentBox').query(".c-readreplies").removeClass('displaynone') ; + }, + hideReadRepliesLnk:function() { + this.overlay.get('contentBox').query(".c-readreplies").addClass('displaynone') ; + }, + changeModeration:function(comment) { + var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; + moderationLnk.set("innerHTML", gettext(comment.state)) ; + + moderationLnk.removeClass("c-state-approved") ; + moderationLnk.removeClass("c-state-pending") ; + moderationLnk.removeClass("c-state-unapproved") ; + moderationLnk.addClass("c-state-" + comment.state) ; - this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; - this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; - }, - isfetched : function() { - return (this.commentId != null) ; - }, - unfetch : function() { - this.commentId = null ; - }, - fetch : function(comment) { - this.commentId = comment.id ; - var boundingBoxNode = this.overlay.get('boundingBox') ; - - if (comment['start_wrapper'] != -1){ - boundingBoxNode.addClass('c-has-scope') ; - boundingBoxNode.removeClass('c-has-no-scope') ; - } - else { - boundingBoxNode.addClass('c-has-no-scope') ; - boundingBoxNode.removeClass('c-has-scope') ; - } - - if (comment['reply_to_id'] != null){ - boundingBoxNode.addClass('c-is-reply') ; - } - else { - boundingBoxNode.removeClass('c-is-reply') ; - } - - // TITLE - var titleInfos = interpolate(gettext('last modified on %(date)s'),{'date':comment.modified_user_str}, true) ; - - var modifDateTooltip = (comment.modified == comment.created) ? '' : ' * ' ; - var permaTitle = gettext('Permalink to this comment') ; - var permalink = ""; - if (sv_prefix=="") { - permalink = '¶ ' ; - } - - var infos = interpolate(gettext('by %(name)s, created on %(date)s'),{'name':comment.name, 'date':comment.created_user_str}, true) ; - - var newTitleContent = '
' + comment.title + permalink + '
' + infos + '
' ; - - var newTitleNode = CY.Node.create(newTitleContent) ; - var prevTitleNode = boundingBoxNode.query(".c-header") ; - if (prevTitleNode == null) // first time, no title yet - boundingBoxNode.query('.icomment-header').insertBefore(newTitleNode, boundingBoxNode.one('.c-iactions')) ; - else - prevTitleNode.get('parentNode').replaceChild(newTitleNode, prevTitleNode) ; + this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; + this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; + }, + isfetched : function() { + return (this.commentId != null) ; + }, + unfetch : function() { + this.commentId = null ; + }, + fetch : function(comment) { + this.commentId = comment.id ; + var boundingBoxNode = this.overlay.get('boundingBox') ; + + if (comment['start_wrapper'] != -1){ + boundingBoxNode.addClass('c-has-scope') ; + boundingBoxNode.removeClass('c-has-no-scope') ; + } + else { + boundingBoxNode.addClass('c-has-no-scope') ; + boundingBoxNode.removeClass('c-has-scope') ; + } + + if (comment['reply_to_id'] != null){ + boundingBoxNode.addClass('c-is-reply') ; + } + else { + boundingBoxNode.removeClass('c-is-reply') ; + } + + // TITLE + var titleInfos = interpolate(gettext('last modified on %(date)s'),{'date':comment.modified_user_str}, true) ; + + var modifDateTooltip = (comment.modified == comment.created) ? '' : ' * ' ; + var permaTitle = gettext('Permalink to this comment') ; + var permalink = ""; + if (sv_prefix=="") { + permalink = '¶ ' ; + } + + var infos = interpolate(gettext('by %(name)s, created on %(date)s'),{'name':comment.name, 'date':comment.created_user_str}, true) ; + + var newTitleContent = '
' + comment.title + permalink + '
' + infos + '
' ; + + var newTitleNode = CY.Node.create(newTitleContent) ; + var prevTitleNode = boundingBoxNode.query(".c-header") ; + if (prevTitleNode == null) // first time, no title yet + boundingBoxNode.query('.icomment-header').insertBefore(newTitleNode, boundingBoxNode.one('.c-iactions')) ; + else + prevTitleNode.get('parentNode').replaceChild(newTitleNode, prevTitleNode) ; - // TAG - var newTagNode = CY.Node.create('
' + 'tags:' + '' + comment.tags + '
') ; - var prevTagNode = boundingBoxNode.query(".c-tags") ; - if (prevTagNode == null) - boundingBoxNode.query('.icomment-header').appendChild(newTagNode) ; - else - prevTagNode.get('parentNode').replaceChild(newTagNode, prevTagNode) ; - // NO TAG ? - if (comment.tags == "") - newTagNode.addClass('displaynone') ; + // TAG + var newTagNode = CY.Node.create('
' + 'tags:' + '' + comment.tags + '
') ; + var prevTagNode = boundingBoxNode.query(".c-tags") ; + if (prevTagNode == null) + boundingBoxNode.query('.icomment-header').appendChild(newTagNode) ; + else + prevTagNode.get('parentNode').replaceChild(newTagNode, prevTagNode) ; + // NO TAG ? + if (comment.tags == "") + newTagNode.addClass('displaynone') ; - // CONTENT - var newContentNode = CY.Node.create('' + comment.content_html + '') ; - var prevContentNode = boundingBoxNode.query(".c-content") ; - if (prevContentNode == null) - boundingBoxNode.query('.icomment-body').appendChild(newContentNode) ; - else - prevContentNode.get('parentNode').replaceChild(newContentNode, prevContentNode) ; + // CONTENT + var newContentNode = CY.Node.create('' + comment.content_html + '') ; + var prevContentNode = boundingBoxNode.query(".c-content") ; + if (prevContentNode == null) + boundingBoxNode.query('.icomment-body').appendChild(newContentNode) ; + else + prevContentNode.get('parentNode').replaceChild(newContentNode, prevContentNode) ; - // PERMALINK - if (sv_prefix=="") { - boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ; - } + // PERMALINK + if (sv_prefix=="") { + boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ; + } - // MODERATION - this.changeModeration(comment) ; + // MODERATION + this.changeModeration(comment) ; /* useless : use implemendted permanentlink instead * - // also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) - var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; - //var cid = (comment.reply_to_id == null) ? this.commentId : "" ; - moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/ /, " ")) ; - - */ - // open links in new window : - var links = boundingBoxNode.queryAll(".c-content a") ; - if (links != null) - links.setAttribute( "target" , "_blank" ) ; - links = boundingBoxNode.queryAll(".c-header-title a") ; - if (links != null) - links.setAttribute( "target" , "_blank" ) ; - - this.permAdapt(comment) ; - }, + // also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) + var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; + //var cid = (comment.reply_to_id == null) ? this.commentId : "" ; + moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/ /, " ")) ; + + */ + // open links in new window : + var links = boundingBoxNode.queryAll(".c-content a") ; + if (links != null) + links.setAttribute( "target" , "_blank" ) ; + links = boundingBoxNode.queryAll(".c-header-title a") ; + if (links != null) + links.setAttribute( "target" , "_blank" ) ; + + this.permAdapt(comment) ; + }, - permAdapt : function(comment) { - // this comment permissions - var delLnk = this.overlay.get('contentBox').query(".c-delete") ; - if (delLnk) { // there will be a server side check anyway - if (!comment.can_delete) - delLnk.addClass('displaynone') ; - else - delLnk.removeClass('displaynone') ; - } + permAdapt : function(comment) { + // this comment permissions + var delLnk = this.overlay.get('contentBox').query(".c-delete") ; + if (delLnk) { // there will be a server side check anyway + if (!comment.can_delete) + delLnk.addClass('displaynone') ; + else + delLnk.removeClass('displaynone') ; + } - var editLnk = this.overlay.get('contentBox').query(".c-edit") ; - if (editLnk) { - if (!comment.can_edit) - editLnk.addClass('displaynone') ; - else - editLnk.removeClass('displaynone') ; - } - - var replyLnk = this.overlay.get('contentBox').query(".c-reply") ; - if (replyLnk) { - if (!hasPerm("can_create_comment")) - replyLnk.addClass('displaynone') ; - else - replyLnk.removeClass('displaynone') ; - } + var editLnk = this.overlay.get('contentBox').query(".c-edit") ; + if (editLnk) { + if (!comment.can_edit) + editLnk.addClass('displaynone') ; + else + editLnk.removeClass('displaynone') ; + } + + var replyLnk = this.overlay.get('contentBox').query(".c-reply") ; + if (replyLnk) { + if (!hasPerm("can_create_comment")) + replyLnk.addClass('displaynone') ; + else + replyLnk.removeClass('displaynone') ; + } - var moderateLnk = this.overlay.get('contentBox').query(".c-moderate") ; - if (moderateLnk) { - if (!comment.can_moderate) - moderateLnk.addClass('displaynone') ; - else - moderateLnk.removeClass('displaynone') ; - } - }, - setThreadPad : function(pad) { // TODO review ... - this.overlay.get('contentBox').query('.yui-widget-hd').setStyle('paddingLeft', pad + 'px') ; - this.overlay.get('contentBox').query('.yui-widget-bd').setStyle('paddingLeft', pad + 'px') ; - - }, - setPosition : function(xy) { - var boundingBoxNode = this.overlay.get('boundingBox') ; + var moderateLnk = this.overlay.get('contentBox').query(".c-moderate") ; + if (moderateLnk) { + if (!comment.can_moderate) + moderateLnk.addClass('displaynone') ; + else + moderateLnk.removeClass('displaynone') ; + } + }, + setThreadPad : function(pad) { // TODO review ... + this.overlay.get('contentBox').query('.yui-widget-hd').setStyle('paddingLeft', pad + 'px') ; + this.overlay.get('contentBox').query('.yui-widget-bd').setStyle('paddingLeft', pad + 'px') ; + + }, + setPosition : function(xy) { + var boundingBoxNode = this.overlay.get('boundingBox') ; - boundingBoxNode.setStyle("opacity", 1); // TODO check this is still usefull - boundingBoxNode.setXY(xy) ; - }, - getPosition : function(xy) { - var boundingBoxNode = this.overlay.get('boundingBox') ; + boundingBoxNode.setStyle("opacity", 1); // TODO check this is still usefull + boundingBoxNode.setXY(xy) ; + }, + getPosition : function(xy) { + var boundingBoxNode = this.overlay.get('boundingBox') ; - return boundingBoxNode.getXY() ; - }, - onAnimationEnd : function() { - if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { - this['animation-handle'].detach() ; - this['animation-handle'] = null ; -// CY.log('detached...') ; - } - gIComments.signalAnimationEnd() ; - if (gIComments.animationsEnded()) - gIComments.whenAnimationsEnd() ; - }, - onAnimationEndFocus : function() { - if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { - this['animation-handle'].detach() ; - this['animation-handle'] = null ; -// CY.log('detached...') ; - } - gIComments.signalAnimationEnd() ; - if (gIComments.animationsEnded()) - gIComments.whenAnimationsEndFocus() ; - }, - onAnimationEndReply : function() { - if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { - this['animation-handle'].detach() ; - this['animation-handle'] = null ; -// CY.log('detached...') ; - } - gIComments.signalAnimationEnd() ; - if (gIComments.animationsEnded()) - gIComments.whenAnimationsEndReply() ; - }, + return boundingBoxNode.getXY() ; + }, + onAnimationEnd : function() { + if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { + this['animation-handle'].detach() ; + this['animation-handle'] = null ; +// CY.log('detached...') ; + } + gIComments.signalAnimationEnd() ; + if (gIComments.animationsEnded()) + gIComments.whenAnimationsEnd() ; + }, + onAnimationEndFocus : function() { + if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { + this['animation-handle'].detach() ; + this['animation-handle'] = null ; +// CY.log('detached...') ; + } + gIComments.signalAnimationEnd() ; + if (gIComments.animationsEnded()) + gIComments.whenAnimationsEndFocus() ; + }, + onAnimationEndReply : function() { + if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { + this['animation-handle'].detach() ; + this['animation-handle'] = null ; +// CY.log('detached...') ; + } + gIComments.signalAnimationEnd() ; + if (gIComments.animationsEnded()) + gIComments.whenAnimationsEndReply() ; + }, - //aa = new CY.Anim({node:gIComments._c[0].overlay.get('boundingBox'), to:{xy : [0,0]}, duration:2.0}) - setAnimationToPosition : function(toXY, focus, reply) { - var boundingBoxNode = this.overlay.get('boundingBox') ; - - // ANIMATION - // 2 lines of optim that could be removed (0.011) - if (gPrefs.get('general','animduration') < 0.011) - boundingBoxNode.setXY(toXY) ; - - this.animation.set('to', { xy: toXY}); - this.animation.set('duration', gPrefs.get('general','animduration')) ; // shouldn't be here really ... + //aa = new CY.Anim({node:gIComments._c[0].overlay.get('boundingBox'), to:{xy : [0,0]}, duration:2.0}) + setAnimationToPosition : function(toXY, focus, reply) { + var boundingBoxNode = this.overlay.get('boundingBox') ; + + // ANIMATION + // 2 lines of optim that could be removed (0.011) + if (gPrefs.get('general','animduration') < 0.011) + boundingBoxNode.setXY(toXY) ; + + this.animation.set('to', { xy: toXY}); + this.animation.set('duration', gPrefs.get('general','animduration')) ; // shouldn't be here really ... if (focus) if (reply) - this['animation-handle'] = this.animation.on('end', this.onAnimationEndReply, this); + this['animation-handle'] = this.animation.on('end', this.onAnimationEndReply, this); else - this['animation-handle'] = this.animation.on('end', this.onAnimationEndFocus, this); + this['animation-handle'] = this.animation.on('end', this.onAnimationEndFocus, this); else - this['animation-handle'] = this.animation.on('end', this.onAnimationEnd, this); - - return this.animation ; - }, - getHeight : function() { - return this.overlay.get('boundingBox').get('offsetHeight') ; - }, - scrollIntoView : function() { - //this.isVisible() && - if (!this.overlay.get('contentBox').inViewportRegion()) - this.overlay.get('contentBox').scrollIntoView(true) ; - }, - _isHostingAForm : function() { - return (this.isVisible() && ((gNewReplyHost != null && gNewReplyHost == this) || (gEditICommentHost != null && gEditICommentHost == this))); - } + this['animation-handle'] = this.animation.on('end', this.onAnimationEnd, this); + + return this.animation ; + }, + getHeight : function() { + return this.overlay.get('boundingBox').get('offsetHeight') ; + }, + scrollIntoView : function() { + //this.isVisible() && + if (!this.overlay.get('contentBox').inViewportRegion()) + this.overlay.get('contentBox').scrollIntoView(true) ; + }, + _isHostingAForm : function() { + return (this.isVisible() && ((gNewReplyHost != null && gNewReplyHost == this) || (gEditICommentHost != null && gEditICommentHost == this))); + } } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_icomments.js --- a/src/cm/media/js/client/c_icomments.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_icomments.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,220 +1,220 @@ // gConf IComments = function() { - // this class manages Comments interface (fetched comments <--> IComment.commentId != null) + // this class manages Comments interface (fetched comments <--> IComment.commentId != null) - this._c = [] ; // IComments instances // commentId == null means is connected to no comment anymore + this._c = [] ; // IComments instances // commentId == null means is connected to no comment anymore - this._a = [] ; // IComments animations to run + this._a = [] ; // IComments animations to run - this._nbEndedAnim = 0 ; + this._nbEndedAnim = 0 ; - this._topActiveCommentDbId = null ; // active + this._topActiveCommentDbId = null ; // active } IComments.prototype = { - init : function (container) { - for (var i = 0 ; i < gConf['iCommentsInitAlloc']; i++) { - this._c.push(new IComment()) ; - } - }, + init : function (container) { + for (var i = 0 ; i < gConf['iCommentsInitAlloc']; i++) { + this._c.push(new IComment()) ; + } + }, - getIComment : function (commentId) { - return CY.Array.find(this._c, function(iComment) { return (iComment.isfetched() && iComment.commentId == commentId) ;}) ; - }, - - insertAfter : function (previousComment, comment) { - var _cids = CY.Array.map(this._c, function(iComment) { return iComment.commentId ; }) ; - var index = CY.Array.indexOf(_cids, previousComment.id) ; - if (index != -1) { - this._c.splice(index + 1, 0, new IComment()) ; // will append when index + 1 == array length - this._c[index + 1].fetch(comment) ; - return this._c[index + 1] ; - } - return null ; - }, - - _remove : function (iComments) { - var toRemoveIds = CY.Array.map(iComments, function(comment) { return comment.commentId ; }) ; - - for (var i = 0 ; i < this._c.length ; i++) { // starting at the bottom to be sure that last remove will be iComment - var iComment2 = this._c[i] ; - if (iComment2.isfetched() && CY.Array.indexOf(toRemoveIds, iComment2.commentId) != -1) { - - iComment2.unfetch() ; + getIComment : function (commentId) { + return CY.Array.find(this._c, function(iComment) { return (iComment.isfetched() && iComment.commentId == commentId) ;}) ; + }, + + insertAfter : function (previousComment, comment) { + var _cids = CY.Array.map(this._c, function(iComment) { return iComment.commentId ; }) ; + var index = CY.Array.indexOf(_cids, previousComment.id) ; + if (index != -1) { + this._c.splice(index + 1, 0, new IComment()) ; // will append when index + 1 == array length + this._c[index + 1].fetch(comment) ; + return this._c[index + 1] ; + } + return null ; + }, + + _remove : function (iComments) { + var toRemoveIds = CY.Array.map(iComments, function(comment) { return comment.commentId ; }) ; + + for (var i = 0 ; i < this._c.length ; i++) { // starting at the bottom to be sure that last remove will be iComment + var iComment2 = this._c[i] ; + if (iComment2.isfetched() && CY.Array.indexOf(toRemoveIds, iComment2.commentId) != -1) { + + iComment2.unfetch() ; - this._c.push(this._c.splice(i, 1)[0]) ; - - i-- ; - } - } - }, - - // all children, comment's IComment included ! - // model based (cf. gDb) - _getChildren : function (commentId) { - return CY.Array.filter(this._c, function(iComment) { return (iComment.isfetched() && gDb.isChild(iComment.commentId,commentId)) ; }) ; - }, + this._c.push(this._c.splice(i, 1)[0]) ; + + i-- ; + } + } + }, + + // all children, comment's IComment included ! + // model based (cf. gDb) + _getChildren : function (commentId) { + return CY.Array.filter(this._c, function(iComment) { return (iComment.isfetched() && gDb.isChild(iComment.commentId,commentId)) ; }) ; + }, - _getInvisibleChildren : function (commentId) { - return CY.Array.filter(this._getChildren(commentId), function(iComment) { return (!iComment.isVisible()) ; }) ; - }, + _getInvisibleChildren : function (commentId) { + return CY.Array.filter(this._getChildren(commentId), function(iComment) { return (!iComment.isVisible()) ; }) ; + }, - // REFRESH (readreplies link etc ?..) - refresh : function (commentId) { - - var iComment = this.getIComment(commentId) ; + // REFRESH (readreplies link etc ?..) + refresh : function (commentId) { + + var iComment = this.getIComment(commentId) ; - var invisibleChildrenIComments = this._getInvisibleChildren(commentId) ; - if (invisibleChildrenIComments.length > 0) //parentIComment is supposed to be visible - iComment.showReadRepliesLnk() ; - else - iComment.hideReadRepliesLnk() ; - }, + var invisibleChildrenIComments = this._getInvisibleChildren(commentId) ; + if (invisibleChildrenIComments.length > 0) //parentIComment is supposed to be visible + iComment.showReadRepliesLnk() ; + else + iComment.hideReadRepliesLnk() ; + }, - remove : function (commentId) { - this._remove(this._getChildren(commentId)) ; - }, + remove : function (commentId) { + this._remove(this._getChildren(commentId)) ; + }, - close : function (commentId) { - CY.Array.each(this._getChildren(commentId), function (iComment) { iComment.hide() ; }) ; - }, + close : function (commentId) { + CY.Array.each(this._getChildren(commentId), function (iComment) { iComment.hide() ; }) ; + }, - open : function (commentId) { - CY.Array.each(this._getChildren(commentId), function (iComment) { iComment.show() ; }) ; - }, + open : function (commentId) { + CY.Array.each(this._getChildren(commentId), function (iComment) { iComment.show() ; }) ; + }, - fetch : function (comments) { - // fill - for (var i = 0 ; i < comments.length; i++) { - if (i == this._c.length) - this._c.push(new IComment()) ; - - this._c[i].fetch(comments[i]) ; - } - - // nullify others - for (var i = comments.length ; i < this._c.length ; i++) { - this._c[i].unfetch() ; - } - }, - - setPosition : function (xy) { - CY.each(this._c, function (iComment) { iComment.setPosition(xy) ; }) ; - }, + fetch : function (comments) { + // fill + for (var i = 0 ; i < comments.length; i++) { + if (i == this._c.length) + this._c.push(new IComment()) ; + + this._c[i].fetch(comments[i]) ; + } + + // nullify others + for (var i = comments.length ; i < this._c.length ; i++) { + this._c[i].unfetch() ; + } + }, + + setPosition : function (xy) { + CY.each(this._c, function (iComment) { iComment.setPosition(xy) ; }) ; + }, - show : function () { - CY.each(this._c, function (iComment) { - if (iComment.isfetched()) { - iComment.show(); - }}) ; - }, - - hide : function () { - this.deactivate(); // to prevent a chain of activate / deactivate while hiding IComments one by one - CY.each(this._c, function (iComment) { if (iComment.commentId != null) iComment.hide(); }) ; - }, - - setWidth : function (colWidth) { - var nextY = null ; - for (var i = 0 ; i < this._c.length; i++) { - var iComment = this._c[i] ; - iComment.setWidth(colWidth) ; - - if (iComment.commentId != null && iComment.isVisible()) { - var xy = iComment.getPosition() ; - if (nextY == null) - nextY = xy[1] ; - xy[1] = nextY ; - iComment.setPosition(xy) ; - nextY += iComment.getHeight() ; - } - } - }, + show : function () { + CY.each(this._c, function (iComment) { + if (iComment.isfetched()) { + iComment.show(); + }}) ; + }, + + hide : function () { + this.deactivate(); // to prevent a chain of activate / deactivate while hiding IComments one by one + CY.each(this._c, function (iComment) { if (iComment.commentId != null) iComment.hide(); }) ; + }, + + setWidth : function (colWidth) { + var nextY = null ; + for (var i = 0 ; i < this._c.length; i++) { + var iComment = this._c[i] ; + iComment.setWidth(colWidth) ; + + if (iComment.commentId != null && iComment.isVisible()) { + var xy = iComment.getPosition() ; + if (nextY == null) + nextY = xy[1] ; + xy[1] = nextY ; + iComment.setPosition(xy) ; + nextY += iComment.getHeight() ; + } + } + }, - getTopPosition:function() { - for (var i = 0 ; i < this._c.length; i++) { - var iComment = this._c[i] ; - if (iComment.commentId != null && iComment.isVisible()) - return iComment.getPosition() ; - } - return null - }, + getTopPosition:function() { + for (var i = 0 ; i < this._c.length; i++) { + var iComment = this._c[i] ; + if (iComment.commentId != null && iComment.isVisible()) + return iComment.getPosition() ; + } + return null + }, - getPosition:function(id) { - for (var i = 0 ; i < this._c.length; i++) { - var iComment = this._c[i] ; - if (iComment.commentId == id && iComment.isVisible()) - return iComment.getPosition() ; - } - return null ; - }, + getPosition:function(id) { + for (var i = 0 ; i < this._c.length; i++) { + var iComment = this._c[i] ; + if (iComment.commentId == id && iComment.isVisible()) + return iComment.getPosition() ; + } + return null ; + }, - setAnimationToPositions : function (y) { - this._initAnimations(); - //CY.log(gPrefs.get('comments','threadpad')) ; - var lpad = (gPrefs.get('comments','threadpad') == '1') ? gConf['iCommentThreadPadding'] : 0 ; // gIThreadPad ... TODO 'configurize' + setAnimationToPositions : function (y) { + this._initAnimations(); + //CY.log(gPrefs.get('comments','threadpad')) ; + var lpad = (gPrefs.get('comments','threadpad') == '1') ? gConf['iCommentThreadPadding'] : 0 ; // gIThreadPad ... TODO 'configurize' - var nextY = y ; - for (var i = 0 ; i < this._c.length;i++) { - var iComment = this._c[i] ; - if (iComment.isfetched && iComment.isVisible()) { - var comment_path = gDb.getPath(gDb.getComment(iComment.commentId)) ; - var iCommentX = ((comment_path.length - 1) * lpad) + gConf['iCommentLeftPadding'] ; + var nextY = y ; + for (var i = 0 ; i < this._c.length;i++) { + var iComment = this._c[i] ; + if (iComment.isfetched && iComment.isVisible()) { + var comment_path = gDb.getPath(gDb.getComment(iComment.commentId)) ; + var iCommentX = ((comment_path.length - 1) * lpad) + gConf['iCommentLeftPadding'] ; - if (nextY == null) { - var xy = iComment.getPosition() ; - nextY = xy[1] ; - } - - this._a.push(iComment.setAnimationToPosition([iCommentX, nextY])) ; - nextY += iComment.getHeight() ; - } - } - }, - - setAnimationToPositionsAndFocus : function (y, focusCommentId, reply) { - this._initAnimations(); - var lpad = (gPrefs.get('comments','threadpad') == '1') ? gConf['iCommentThreadPadding'] : 0 ; + if (nextY == null) { + var xy = iComment.getPosition() ; + nextY = xy[1] ; + } + + this._a.push(iComment.setAnimationToPosition([iCommentX, nextY])) ; + nextY += iComment.getHeight() ; + } + } + }, + + setAnimationToPositionsAndFocus : function (y, focusCommentId, reply) { + this._initAnimations(); + var lpad = (gPrefs.get('comments','threadpad') == '1') ? gConf['iCommentThreadPadding'] : 0 ; - var nextY = y ; - for (var i = 0 ; i < this._c.length;i++) { - var iComment = this._c[i] ; - if (iComment.isfetched && iComment.isVisible()) { - var comment_path = gDb.getPath(gDb.getComment(iComment.commentId)) ; - var iCommentX = ((comment_path.length - 1) * lpad) + gConf['iCommentLeftPadding'] ; + var nextY = y ; + for (var i = 0 ; i < this._c.length;i++) { + var iComment = this._c[i] ; + if (iComment.isfetched && iComment.isVisible()) { + var comment_path = gDb.getPath(gDb.getComment(iComment.commentId)) ; + var iCommentX = ((comment_path.length - 1) * lpad) + gConf['iCommentLeftPadding'] ; - if (nextY == null) { - var xy = iComment.getPosition() ; - nextY = xy[1] ; - } - + if (nextY == null) { + var xy = iComment.getPosition() ; + nextY = xy[1] ; + } + if (iComment.commentId >= focusCommentId) - this._a.push(iComment.setAnimationToPosition([iCommentX, nextY], focusCommentId, reply)) ; + this._a.push(iComment.setAnimationToPosition([iCommentX, nextY], focusCommentId, reply)) ; else - this._a.push(iComment.setAnimationToPosition([iCommentX, nextY])) ; - nextY += iComment.getHeight() ; - } - } - }, - -// ANIMATION FUNCTIONS - _initAnimations : function () { - this._a = [] ; - this._nbEndedAnim = 0 ; - }, - - runAnimations : function () { - if (this._a.length == 0) // will occur when closing last displayed comment - gSync.resetAutoContinue("animationRun") ; - else - CY.each(this._a, function (animation) { animation.run() ; }) ; - }, - - whenAnimationsEnd : function () { - gSync.resume() ; - }, - - whenAnimationsEndFocus : function () { + this._a.push(iComment.setAnimationToPosition([iCommentX, nextY])) ; + nextY += iComment.getHeight() ; + } + } + }, + +// ANIMATION FUNCTIONS + _initAnimations : function () { + this._a = [] ; + this._nbEndedAnim = 0 ; + }, + + runAnimations : function () { + if (this._a.length == 0) // will occur when closing last displayed comment + gSync.resetAutoContinue("animationRun") ; + else + CY.each(this._a, function (animation) { animation.run() ; }) ; + }, + + whenAnimationsEnd : function () { + gSync.resume() ; + }, + + whenAnimationsEndFocus : function () { gGETValues = CY.JSON.parse(sv_get_params); if ("comment_id_key" in gGETValues) { var id_key = gGETValues["comment_id_key"]; @@ -222,10 +222,10 @@ if (focusComment != null) gIComments.getIComment(focusComment.id).overlay.focus(); } - gSync.resume(); - }, - - whenAnimationsEndReply : function () { + gSync.resume(); + }, + + whenAnimationsEndReply : function () { gGETValues = CY.JSON.parse(sv_get_params); if ("comment_id_key" in gGETValues) { var id_key = gGETValues["comment_id_key"]; @@ -234,110 +234,110 @@ gSync.showReplyForm(gIComments.getIComment(focusComment.id)); } } - gSync.resume(); - }, - - animationsEnded : function () { - return ((this._a.length == 0) || (this._a.length == this._nbEndedAnim)) ; - }, - - signalAnimationEnd : function () { - this._nbEndedAnim++ ; - }, - -// ACTIVE RELATED FUNCTIONS - // returns true only for the top iComment - isTopActive : function(commentDbId) { - return ((commentDbId != null) && (this._topActiveCommentDbId == commentDbId)) ; - }, - - isAnyActive : function() { - return (this._topActiveCommentDbId != null) ; - }, - - //warning : calling this function "focus" would make IE get mad - activate : function(commentDbId) { - - if (this._topActiveCommentDbId != null) {// then deactivate current - this.deactivate() ; - } + gSync.resume(); + }, + + animationsEnded : function () { + return ((this._a.length == 0) || (this._a.length == this._nbEndedAnim)) ; + }, + + signalAnimationEnd : function () { + this._nbEndedAnim++ ; + }, + +// ACTIVE RELATED FUNCTIONS + // returns true only for the top iComment + isTopActive : function(commentDbId) { + return ((commentDbId != null) && (this._topActiveCommentDbId == commentDbId)) ; + }, + + isAnyActive : function() { + return (this._topActiveCommentDbId != null) ; + }, + + //warning : calling this function "focus" would make IE get mad + activate : function(commentDbId) { + + if (this._topActiveCommentDbId != null) {// then deactivate current + this.deactivate() ; + } - // activate whole top parent thread - var comment = gDb.getComment(commentDbId) ; - var comment_path = gDb.getPath(comment) ; - var topParent = comment_path[comment_path.length - 1] ; - - var iComments = this._getChildren(topParent.id) ; - CY.Array.each(iComments, function(iComment){iComment.activate();}) ; + // activate whole top parent thread + var comment = gDb.getComment(commentDbId) ; + var comment_path = gDb.getPath(comment) ; + var topParent = comment_path[comment_path.length - 1] ; + + var iComments = this._getChildren(topParent.id) ; + CY.Array.each(iComments, function(iComment){iComment.activate();}) ; - this._topActiveCommentDbId = topParent.id ; + this._topActiveCommentDbId = topParent.id ; - // update browser index - if (gLayout.isInFrame()) { - var indxDict = gDb.browsingIndex(this._topActiveCommentDbId) ; - parent.$("#browse_by option").each(function() { - var rank = 1 + indxDict[this.value] ; - parent.$("#c_browse_indx_"+this.value).html(''+ rank) ; - }) ; - } - - showScope(topParent.id) ; - }, - - deactivate : function() { - if (this._topActiveCommentDbId != null) { - parent.$("#browse_by option").each(function() { - parent.$("#c_browse_indx_"+this.value).html('-') ; - }) ; + // update browser index + if (gLayout.isInFrame()) { + var indxDict = gDb.browsingIndex(this._topActiveCommentDbId) ; + parent.$("#browse_by option").each(function() { + var rank = 1 + indxDict[this.value] ; + parent.$("#c_browse_indx_"+this.value).html(''+ rank) ; + }) ; + } + + showScope(topParent.id) ; + }, + + deactivate : function() { + if (this._topActiveCommentDbId != null) { + parent.$("#browse_by option").each(function() { + parent.$("#c_browse_indx_"+this.value).html('-') ; + }) ; - // scopes - hideScopeAnyway() ; - - var iComments = this._getChildren(this._topActiveCommentDbId) ; - CY.Array.each(iComments, function(iComment){iComment.deactivate();}) ; + // scopes + hideScopeAnyway() ; + + var iComments = this._getChildren(this._topActiveCommentDbId) ; + CY.Array.each(iComments, function(iComment){iComment.deactivate();}) ; - this._topActiveCommentDbId = null ; - } - }, + this._topActiveCommentDbId = null ; + } + }, - // active next IComment among the displayed ones (try below and if couldn't try above) - // model based - activateVisibleNext : function() { - - if (this._topActiveCommentDbId != null) { + // active next IComment among the displayed ones (try below and if couldn't try above) + // model based + activateVisibleNext : function() { + + if (this._topActiveCommentDbId != null) { - for (var j = 0 ; j < 2 ; j++) { - - var start = (j==0) ? 0 : this._c.length - 1 ; - - var b = false ; - - for (var i = start ; (i >= 0) && i <= (this._c.length - 1) ;) { - var iComment = this._c[i] ; - - if (iComment.commentId != null && iComment.isVisible()) { - b = b || (gDb.isChild(iComment.commentId,this._topActiveCommentDbId)) ; - if (b && (!gDb.isChild(iComment.commentId,this._topActiveCommentDbId))) { // found the one below that doesn't have topActive as parent - this.activate(iComment.commentId) ; - return true ; - } - } - i = (j == 0) ? i + 1 : i - 1 ; - } - } - } - return false ; - }, - - browse : function(order, whereto) { - var wt = whereto ; - if ((whereto == "prev") && !this.isAnyActive()) { - wt = "last" ; - } - if ((whereto == "next") && !this.isAnyActive()) { - wt = "first" ; - } - return gDb.browse(order, wt, this._topActiveCommentDbId) ; - } - + for (var j = 0 ; j < 2 ; j++) { + + var start = (j==0) ? 0 : this._c.length - 1 ; + + var b = false ; + + for (var i = start ; (i >= 0) && i <= (this._c.length - 1) ;) { + var iComment = this._c[i] ; + + if (iComment.commentId != null && iComment.isVisible()) { + b = b || (gDb.isChild(iComment.commentId,this._topActiveCommentDbId)) ; + if (b && (!gDb.isChild(iComment.commentId,this._topActiveCommentDbId))) { // found the one below that doesn't have topActive as parent + this.activate(iComment.commentId) ; + return true ; + } + } + i = (j == 0) ? i + 1 : i - 1 ; + } + } + } + return false ; + }, + + browse : function(order, whereto) { + var wt = whereto ; + if ((whereto == "prev") && !this.isAnyActive()) { + wt = "last" ; + } + if ((whereto == "next") && !this.isAnyActive()) { + wt = "first" ; + } + return gDb.browse(order, wt, this._topActiveCommentDbId) ; + } + } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_interface_forms.js --- a/src/cm/media/js/client/c_interface_forms.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_interface_forms.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,71 +1,71 @@ gNoSelectionYet = gettext("No selection yet") ; gFormHtml = { - 'formStart' :'
', - 'nameInput' :gettext('Username:') + '
', - 'emailInput' :gettext('E-mail address:') + '
', - 'titleInput' :gettext('Title:') + '
', - 'contentInput' :gettext("Content:") + '
', - 'tagsInput' :gettext("Tag:") + '
', - 'hidden' :'', - 'formEnd' :'
', - 'changeScope' :'
' + gettext("Modify comment's scope:") + '
', - 'headerTitle' :'
', - 'currentSel' :'
' + gettext('Comment will apply to this selection:') + '
' + gNoSelectionYet + '
#hiddeninput#
', - 'btns' :'
', - 'closeIcon' :'      ' - } ; + 'formStart' :'
', + 'nameInput' :gettext('Username:') + '
', + 'emailInput' :gettext('E-mail address:') + '
', + 'titleInput' :gettext('Title:') + '
', + 'contentInput' :gettext("Content:") + '
', + 'tagsInput' :gettext("Tag:") + '
', + 'hidden' :'', + 'formEnd' :'
', + 'changeScope' :'
' + gettext("Modify comment's scope:") + '
', + 'headerTitle' :'
', + 'currentSel' :'
' + gettext('Comment will apply to this selection:') + '
' + gNoSelectionYet + '
#hiddeninput#
', + 'btns' :'
', + 'closeIcon' :'      ' + } ; // returns {'headerContent':headerHtml, 'bodyContent':bodyHtml} getHtml = function(ids) { - ret = {} ; - ret['headerContent'] = '' ; - - if ('closeBtnId' in ids) - ret['headerContent'] += gFormHtml['closeIcon'].replace('###', ids['closeBtnId']) ; - - ret['headerContent'] += gFormHtml['headerTitle'].replace('###', ids['formTitleId']) ; + ret = {} ; + ret['headerContent'] = '' ; + + if ('closeBtnId' in ids) + ret['headerContent'] += gFormHtml['closeIcon'].replace('###', ids['closeBtnId']) ; + + ret['headerContent'] += gFormHtml['headerTitle'].replace('###', ids['formTitleId']) ; - var selEditChkBoxHtml = "" ; - if ('changeScopeInputId' in ids) - selEditChkBoxHtml = gFormHtml['changeScope'].replace('###', ids['changeScopeInputId']) ; - - var hiddenInput = '
'+gFormHtml['hidden'].replace('###', ids['selectionPlaceId']).replace('???', 'selection_place')+'
' ; - var selectionTitleHtml = gFormHtml['currentSel'].replace('###', ids['currentSelId']).replace('???', ids['currentSelIdI']).replace('#hiddeninput#', hiddenInput) ; - - var btnsHtml = gFormHtml['btns'].replace('###', ids['addBtnId']).replace('???', ids['cancelBtnId']) ; - - var html = gFormHtml['formStart'].replace('###', ids['formId']) + selEditChkBoxHtml + selectionTitleHtml ; - - if ('nameInputId' in ids) - html = html + gFormHtml['nameInput'].replace('###', ids['nameInputId']) ; - if ('emailInputId' in ids) - html = html + gFormHtml['emailInput'].replace('###', ids['emailInputId']) ; - - html = html + gFormHtml['titleInput'].replace('###', ids['titleInputId']) + gFormHtml['contentInput'].replace('###', ids['contentInputId']) + gFormHtml['tagsInput'].replace('###', ids['tagsInputId']); - html = html + gFormHtml['hidden'].replace('###', ids['formatInputId']).replace('???', 'format') ; - html = html + gFormHtml['hidden'].replace('###', ids['startWrapperInputId']).replace('???', 'start_wrapper') ; - html = html + gFormHtml['hidden'].replace('###', ids['endWrapperInputId']).replace('???', 'end_wrapper') ; - html = html + gFormHtml['hidden'].replace('###', ids['startOffsetInputId']).replace('???', 'start_offset') ; - html = html + gFormHtml['hidden'].replace('###', ids['endOffsetInputId']).replace('???', 'end_offset') ; - html = html + gFormHtml['hidden'].replace('###', ids['keyId']).replace('???', 'comment_key') ; - html = html + gFormHtml['hidden'].replace('###', ids['editCommentId']).replace('???', 'edit_comment_id') ; - html = html + btnsHtml + gFormHtml['formEnd'] ; - ret['bodyContent'] = html ; - return ret ; + var selEditChkBoxHtml = "" ; + if ('changeScopeInputId' in ids) + selEditChkBoxHtml = gFormHtml['changeScope'].replace('###', ids['changeScopeInputId']) ; + + var hiddenInput = '
'+gFormHtml['hidden'].replace('###', ids['selectionPlaceId']).replace('???', 'selection_place')+'
' ; + var selectionTitleHtml = gFormHtml['currentSel'].replace('###', ids['currentSelId']).replace('???', ids['currentSelIdI']).replace('#hiddeninput#', hiddenInput) ; + + var btnsHtml = gFormHtml['btns'].replace('###', ids['addBtnId']).replace('???', ids['cancelBtnId']) ; + + var html = gFormHtml['formStart'].replace('###', ids['formId']) + selEditChkBoxHtml + selectionTitleHtml ; + + if ('nameInputId' in ids) + html = html + gFormHtml['nameInput'].replace('###', ids['nameInputId']) ; + if ('emailInputId' in ids) + html = html + gFormHtml['emailInput'].replace('###', ids['emailInputId']) ; + + html = html + gFormHtml['titleInput'].replace('###', ids['titleInputId']) + gFormHtml['contentInput'].replace('###', ids['contentInputId']) + gFormHtml['tagsInput'].replace('###', ids['tagsInputId']); + html = html + gFormHtml['hidden'].replace('###', ids['formatInputId']).replace('???', 'format') ; + html = html + gFormHtml['hidden'].replace('###', ids['startWrapperInputId']).replace('???', 'start_wrapper') ; + html = html + gFormHtml['hidden'].replace('###', ids['endWrapperInputId']).replace('???', 'end_wrapper') ; + html = html + gFormHtml['hidden'].replace('###', ids['startOffsetInputId']).replace('???', 'start_offset') ; + html = html + gFormHtml['hidden'].replace('###', ids['endOffsetInputId']).replace('???', 'end_offset') ; + html = html + gFormHtml['hidden'].replace('###', ids['keyId']).replace('???', 'comment_key') ; + html = html + gFormHtml['hidden'].replace('###', ids['editCommentId']).replace('???', 'edit_comment_id') ; + html = html + btnsHtml + gFormHtml['formEnd'] ; + ret['bodyContent'] = html ; + return ret ; } ; changeFormFieldsWidth = function(formId, val) { - var fieldWidth = (val - 20) +'px' ; - var elts = CY.all("#" + formId + " input[type='text']") ; - if (elts != null) - elts.setStyle("width", fieldWidth) ; - elts = CY.all("#" + formId + " textarea") ; - if (elts != null) - elts.setStyle("width", fieldWidth) ; + var fieldWidth = (val - 20) +'px' ; + var elts = CY.all("#" + formId + " input[type='text']") ; + if (elts != null) + elts.setStyle("width", fieldWidth) ; + elts = CY.all("#" + formId + " textarea") ; + if (elts != null) + elts.setStyle("width", fieldWidth) ; } addFormErrMsg = function(formId, eltName, errorString) { - var formElt = document.getElementById(formId) ; + var formElt = document.getElementById(formId) ; var i, e, s, ilen ; // Iterate over the form elements collection to construct the @@ -73,14 +73,14 @@ for (i = 0, ilen = formElt.elements.length; i < ilen; ++i) { e = formElt.elements[i]; if (e.name == eltName) { - s = document.createElement('DIV') ; - CY.DOM.addClass(s, 'c-error') ; - s.id = e.id + '-err'; - s.appendChild(document.createTextNode(errorString)) ; - if (e.parentNode.nextSibling) - e.parentNode.parentNode.insertBefore(s, e.parentNode.nextSibling) ; - else - e.parentNode.parentNode.appendChild(s) ; + s = document.createElement('DIV') ; + CY.DOM.addClass(s, 'c-error') ; + s.id = e.id + '-err'; + s.appendChild(document.createTextNode(errorString)) ; + if (e.parentNode.nextSibling) + e.parentNode.parentNode.insertBefore(s, e.parentNode.nextSibling) ; + else + e.parentNode.parentNode.appendChild(s) ; } } @@ -88,8 +88,8 @@ // frames['text_view_frame'].removeFormErrMsg(frames['text_view_frame'].gICommentForm['formId']) removeFormErrMsg = function(formId) { - var nodes = CY.all('#'+formId+' .c-error'); - if (nodes != null) - nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ; + var nodes = CY.all('#'+formId+' .c-error'); + if (nodes != null) + nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_layout.js --- a/src/cm/media/js/client/c_layout.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_layout.js Tue Nov 30 09:53:35 2010 +0100 @@ -4,58 +4,58 @@ } Layout.prototype = { - init : function () { - }, - - isInFrame : function () { - return (!CY.Lang.isUndefined(parent) && parent.location != location && CY.Lang.isFunction(parent.f_getFrameFilterData)); ; - }, - - isInComentSite : function () { - var ret = false; - try { - if (!CY.Lang.isUndefined(sv_site_url) && !CY.Lang.isUndefined(parent) && !CY.Lang.isUndefined(parent.parent)) { - var parentParentLocation = new String(parent.parent.location) ; - // TODO warn server - //CY.log(parentParentLocation) ; - ret = (parentParentLocation.indexOf(sv_site_url) == 0); - } - } - catch (e) { - ret=false; - //CY.log("error thrown while trying to access parent.parent.location") ; - } - //CY.log("inComentSite returned : " + ret) ; - return ret ; - }, - - sliderValToPx : function (val) { - var winWidth = CY.DOM.winWidth() ; - if (this.isInFrame()) - winWidth = parent.$(parent).width() ; - var theta = val / 100 ; - theta = Math.min(theta, gConf['sliderFixedMin']) ; - theta = Math.max(theta, gConf['sliderFixedMax']) ; - var colWidth = theta * winWidth ; - return Math.floor(colWidth) ; - }, + init : function () { + }, + + isInFrame : function () { + return (!CY.Lang.isUndefined(parent) && parent.location != location && CY.Lang.isFunction(parent.f_getFrameFilterData)); ; + }, + + isInComentSite : function () { + var ret = false; + try { + if (!CY.Lang.isUndefined(sv_site_url) && !CY.Lang.isUndefined(parent) && !CY.Lang.isUndefined(parent.parent)) { + var parentParentLocation = new String(parent.parent.location) ; + // TODO warn server + //CY.log(parentParentLocation) ; + ret = (parentParentLocation.indexOf(sv_site_url) == 0); + } + } + catch (e) { + ret=false; + //CY.log("error thrown while trying to access parent.parent.location") ; + } + //CY.log("inComentSite returned : " + ret) ; + return ret ; + }, + + sliderValToPx : function (val) { + var winWidth = CY.DOM.winWidth() ; + if (this.isInFrame()) + winWidth = parent.$(parent).width() ; + var theta = val / 100 ; + theta = Math.min(theta, gConf['sliderFixedMin']) ; + theta = Math.max(theta, gConf['sliderFixedMax']) ; + var colWidth = theta * winWidth ; + return Math.floor(colWidth) ; + }, - getTopICommentsWidth : function() { - return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get('layout','comments_col_width'))) ; - }, - - getTopICommentsWidthFromWidth : function(val) { - var ret = val - ( 2 * gConf['iCommentThreadPadding']) ; // PhA said : a threaded discussion with a depth of 2 still shoudn't hide the text 20100317 - return ret - 7; - }, - - setLeftColumnWidth : function (colWidth) { - CY.get('#contentcolumn').setStyle('marginLeft', colWidth + 'px'); - CY.get('#leftcolumn').setStyle('width', colWidth + 'px'); - }, - parentInterfaceUnfreeze : function() { - if (this.isInFrame()) - parent.f_interfaceUnfreeze() ; - } - + getTopICommentsWidth : function() { + return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get('layout','comments_col_width'))) ; + }, + + getTopICommentsWidthFromWidth : function(val) { + var ret = val - ( 2 * gConf['iCommentThreadPadding']) ; // PhA said : a threaded discussion with a depth of 2 still shoudn't hide the text 20100317 + return ret - 7; + }, + + setLeftColumnWidth : function (colWidth) { + CY.get('#contentcolumn').setStyle('marginLeft', colWidth + 'px'); + CY.get('#leftcolumn').setStyle('width', colWidth + 'px'); + }, + parentInterfaceUnfreeze : function() { + if (this.isInFrame()) + parent.f_interfaceUnfreeze() ; + } + } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_permissions.js --- a/src/cm/media/js/client/c_permissions.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_permissions.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,3 +1,3 @@ hasPerm = function(label) { - return (-1 != CY.Array.indexOf(sv_user_permissions, label)) ; + return (-1 != CY.Array.indexOf(sv_user_permissions, label)) ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_preferences.js --- a/src/cm/media/js/client/c_preferences.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_preferences.js Tue Nov 30 09:53:35 2010 +0100 @@ -5,52 +5,52 @@ // YUI3 used: cookie Preferences = function() { - this.prefs = {} ; + this.prefs = {} ; } Preferences.prototype = { - init : function() { - this._read() ; - }, - //read user preferences from cookie - _read : function() { - for (var key1 in gConf['defaultPrefs']) { - - this.prefs[key1] = {} ; - - for (var key2 in gConf['defaultPrefs'][key1]) { + init : function() { + this._read() ; + }, + //read user preferences from cookie + _read : function() { + for (var key1 in gConf['defaultPrefs']) { + + this.prefs[key1] = {} ; + + for (var key2 in gConf['defaultPrefs'][key1]) { - var val = null ; - if (key1 == 'user' && (key2 == 'name' || key2 == 'email')) - val = CY.Cookie.get("user_" + key2); - else - val = CY.Cookie.getSub(key1, key2); - this.prefs[key1][key2] = (val == null) ? gConf['defaultPrefs'][key1][key2] : val ; - } - } - }, - // to be used only on values in gDefaultPrefs - persist : function(key1, key2, val) { - var cookieOptions = {path:"/", expires:(new Date()).setFullYear(2100,0,1)} ; - - if (key1 == 'user' && (key2 == 'name' || key2 == 'email')) // special case want to get that from cookie set up by python code - CY.Cookie.set("user_" + key2, val, cookieOptions); - else - CY.Cookie.setSub(key1, key2, val, cookieOptions); - this.prefs[key1][key2] = val ; - }, - get : function(key1, key2) { - return this.prefs[key1][key2] ; - }, - readDefault : function(key1, key2) { - return gConf['defaultPrefs'][key1][key2] ; - }, - reset : function(entries) { - for (var i = 0; i < entries.length ; i++) { - var key1 = entries[i] ; - for (var key2 in gConf['defaultPrefs'][key1]) { - this.persist(key1, key2, gConf['defaultPrefs'][key1][key2]) ; - } - } - } + var val = null ; + if (key1 == 'user' && (key2 == 'name' || key2 == 'email')) + val = CY.Cookie.get("user_" + key2); + else + val = CY.Cookie.getSub(key1, key2); + this.prefs[key1][key2] = (val == null) ? gConf['defaultPrefs'][key1][key2] : val ; + } + } + }, + // to be used only on values in gDefaultPrefs + persist : function(key1, key2, val) { + var cookieOptions = {path:"/", expires:(new Date()).setFullYear(2100,0,1)} ; + + if (key1 == 'user' && (key2 == 'name' || key2 == 'email')) // special case want to get that from cookie set up by python code + CY.Cookie.set("user_" + key2, val, cookieOptions); + else + CY.Cookie.setSub(key1, key2, val, cookieOptions); + this.prefs[key1][key2] = val ; + }, + get : function(key1, key2) { + return this.prefs[key1][key2] ; + }, + readDefault : function(key1, key2) { + return gConf['defaultPrefs'][key1][key2] ; + }, + reset : function(entries) { + for (var i = 0; i < entries.length ; i++) { + var key1 = entries[i] ; + for (var key2 in gConf['defaultPrefs'][key1]) { + this.persist(key1, key2, gConf['defaultPrefs'][key1][key2]) ; + } + } + } } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_reply_form.js --- a/src/cm/media/js/client/c_reply_form.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_reply_form.js Tue Nov 30 09:53:35 2010 +0100 @@ -2,121 +2,121 @@ gNewReply = null instanciateNewReplyForm = function(iCommentToAppendTo) { - - if (gNewReply == null) { - gNewReply = { - 'val': { - 'name':gPrefs.get('user','name'), - 'email':gPrefs.get('user','email'), - 'title':'', - 'content':'', - 'tags':''}, - 'ids': { - 'name':gPrefs.get('user','name'), - 'email':gPrefs.get('user','email'), - 'title':'', - 'content':'', - 'tags':'', - 'formId':CY.guid(), - 'nameInputId':CY.guid(), - 'emailInputId':CY.guid(), - 'titleInputId':CY.guid(), - 'contentInputId':CY.guid(), - 'keyInputId':CY.guid(), - 'formatInputId':CY.guid(), - 'tagsInputId':CY.guid(), - 'parentCommentId':CY.guid(), - 'addBtnId':CY.guid(), - 'cancelBtnId':CY.guid()}, - 'handlers':{} - } ; - } + + if (gNewReply == null) { + gNewReply = { + 'val': { + 'name':gPrefs.get('user','name'), + 'email':gPrefs.get('user','email'), + 'title':'', + 'content':'', + 'tags':''}, + 'ids': { + 'name':gPrefs.get('user','name'), + 'email':gPrefs.get('user','email'), + 'title':'', + 'content':'', + 'tags':'', + 'formId':CY.guid(), + 'nameInputId':CY.guid(), + 'emailInputId':CY.guid(), + 'titleInputId':CY.guid(), + 'contentInputId':CY.guid(), + 'keyInputId':CY.guid(), + 'formatInputId':CY.guid(), + 'tagsInputId':CY.guid(), + 'parentCommentId':CY.guid(), + 'addBtnId':CY.guid(), + 'cancelBtnId':CY.guid()}, + 'handlers':{} + } ; + } - gNewReplyHost = iCommentToAppendTo ; + gNewReplyHost = iCommentToAppendTo ; - var headerHtml = '
' + gettext('New reply') + '
' ; - var html = gFormHtml['formStart'].replace('###', gNewReply['ids']['formId']) ; - if (!sv_loggedIn) { - html = html + gFormHtml['nameInput'].replace('###', gNewReply['ids']['nameInputId']) + gFormHtml['emailInput'].replace('###', gNewReply['ids']['emailInputId']) ; - } - html = html + gFormHtml['titleInput'].replace('###', gNewReply['ids']['titleInputId']) + gFormHtml['contentInput'].replace('###', gNewReply['ids']['contentInputId']) + gFormHtml['tagsInput'].replace('###', gNewReply['ids']['tagsInputId']); - html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['keyInputId']).replace('???', 'comment_key') ; - html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['formatInputId']).replace('???', 'format') ; - html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['parentCommentId']).replace('???', 'reply_to_id') ; - var btnsHtml = gFormHtml['btns'].replace('###', gNewReply['ids']['addBtnId']).replace('???', gNewReply['ids']['cancelBtnId']) ; - - gNewReplyHost['overlay'].setStdModContent(CY.WidgetStdMod.FOOTER, headerHtml + html + btnsHtml) ; - var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; + var headerHtml = '
' + gettext('New reply') + '
' ; + var html = gFormHtml['formStart'].replace('###', gNewReply['ids']['formId']) ; + if (!sv_loggedIn) { + html = html + gFormHtml['nameInput'].replace('###', gNewReply['ids']['nameInputId']) + gFormHtml['emailInput'].replace('###', gNewReply['ids']['emailInputId']) ; + } + html = html + gFormHtml['titleInput'].replace('###', gNewReply['ids']['titleInputId']) + gFormHtml['contentInput'].replace('###', gNewReply['ids']['contentInputId']) + gFormHtml['tagsInput'].replace('###', gNewReply['ids']['tagsInputId']); + html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['keyInputId']).replace('???', 'comment_key') ; + html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['formatInputId']).replace('???', 'format') ; + html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['parentCommentId']).replace('???', 'reply_to_id') ; + var btnsHtml = gFormHtml['btns'].replace('###', gNewReply['ids']['addBtnId']).replace('???', gNewReply['ids']['cancelBtnId']) ; + + gNewReplyHost['overlay'].setStdModContent(CY.WidgetStdMod.FOOTER, headerHtml + html + btnsHtml) ; + var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; - var comment = gDb.getComment(iCommentToAppendTo.commentId) ; - var REPLYPREF = "Re: " ; - var newReplyTitle = (gNewReply['val']['title'] == "" || gNewReply['val']['title'].substring(0, REPLYPREF.length) == REPLYPREF) ? REPLYPREF + comment['title'] : gNewReply['val']['title'] ; + var comment = gDb.getComment(iCommentToAppendTo.commentId) ; + var REPLYPREF = "Re: " ; + var newReplyTitle = (gNewReply['val']['title'] == "" || gNewReply['val']['title'].substring(0, REPLYPREF.length) == REPLYPREF) ? REPLYPREF + comment['title'] : gNewReply['val']['title'] ; - if (!sv_loggedIn) { - replyNode.query('.n_name').set('value', gNewReply['val']['name']) ; - replyNode.query('.n_email').set('value', gNewReply['val']['email']) ; - } - replyNode.query('.n_title').set('value', newReplyTitle) ; - replyNode.query('.n_content').set('value', gNewReply['val']['content']) ; - replyNode.query('.n_tags').set('value', gNewReply['val']['tags']) ; - - replyNode.query('#'+gNewReply['ids']['parentCommentId']).set('value', iCommentToAppendTo['commentId']) ; - replyNode.query('#'+gNewReply['ids']['formatInputId']).set('value', gConf['defaultCommentFormat']) ; - - gNewReplyHost['overlay'].get('contentBox').query(".c-reply").addClass('displaynone') ; + if (!sv_loggedIn) { + replyNode.query('.n_name').set('value', gNewReply['val']['name']) ; + replyNode.query('.n_email').set('value', gNewReply['val']['email']) ; + } + replyNode.query('.n_title').set('value', newReplyTitle) ; + replyNode.query('.n_content').set('value', gNewReply['val']['content']) ; + replyNode.query('.n_tags').set('value', gNewReply['val']['tags']) ; + + replyNode.query('#'+gNewReply['ids']['parentCommentId']).set('value', iCommentToAppendTo['commentId']) ; + replyNode.query('#'+gNewReply['ids']['formatInputId']).set('value', gConf['defaultCommentFormat']) ; + + gNewReplyHost['overlay'].get('contentBox').query(".c-reply").addClass('displaynone') ; - gNewReply['handlers']['addBtnId'] = CY.on("click", onAddNewReplyClick, "#"+gNewReply['ids']['addBtnId']); - gNewReply['handlers']['cancelBtnId'] = CY.on("click", onCancelNewReplyClick, "#"+gNewReply['ids']['cancelBtnId']); - - var width = gLayout.getTopICommentsWidth() ; - changeFormFieldsWidth(gNewReply['ids']['formId'], width) ; + gNewReply['handlers']['addBtnId'] = CY.on("click", onAddNewReplyClick, "#"+gNewReply['ids']['addBtnId']); + gNewReply['handlers']['cancelBtnId'] = CY.on("click", onCancelNewReplyClick, "#"+gNewReply['ids']['cancelBtnId']); + + var width = gLayout.getTopICommentsWidth() ; + changeFormFieldsWidth(gNewReply['ids']['formId'], width) ; CY.get("#"+gNewReply['ids']['contentInputId']).focus(); } cleanNewReplyForm = function() { - if (gNewReplyHost != null) { - var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; - replyNode.queryAll('.comment_input').set('value','') ; - } + if (gNewReplyHost != null) { + var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; + replyNode.queryAll('.comment_input').set('value','') ; + } } cancelNewReplyForm = function() { - if (gNewReplyHost != null) { - - // DETACH EVENT HANDLERS - for (var id in gNewReply['handlers']) { - if (gNewReply['handlers'][id] != null) { - gNewReply['handlers'][id].detach() ; - gNewReply['handlers'][id] = null ; - } - } + if (gNewReplyHost != null) { + + // DETACH EVENT HANDLERS + for (var id in gNewReply['handlers']) { + if (gNewReply['handlers'][id] != null) { + gNewReply['handlers'][id].detach() ; + gNewReply['handlers'][id] = null ; + } + } - gNewReplyHost['overlay'].get('contentBox').query(".c-reply").removeClass('displaynone') ; - - var footer = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; - if (!sv_loggedIn) { - gNewReply['val']['name'] = footer.query('.n_name').get('value') ; - gNewReply['val']['email'] = footer.query('.n_email').get('value') ; - } - gNewReply['val']['title'] = footer.query('.n_title').get('value') ; - gNewReply['val']['content'] = footer.query('.n_content').get('value') ; - gNewReply['val']['tags'] = footer.query('.n_tags').get('value') ; - - footer.set('innerHTML', '') ; - - gNewReplyHost = null ; - } + gNewReplyHost['overlay'].get('contentBox').query(".c-reply").removeClass('displaynone') ; + + var footer = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; + if (!sv_loggedIn) { + gNewReply['val']['name'] = footer.query('.n_name').get('value') ; + gNewReply['val']['email'] = footer.query('.n_email').get('value') ; + } + gNewReply['val']['title'] = footer.query('.n_title').get('value') ; + gNewReply['val']['content'] = footer.query('.n_content').get('value') ; + gNewReply['val']['tags'] = footer.query('.n_tags').get('value') ; + + footer.set('innerHTML', '') ; + + gNewReplyHost = null ; + } } // event triggered onAddNewReplyClick = function() { - if (!sv_loggedIn) { - var name = CY.get("#"+gNewReply['ids']['nameInputId']).get('value') ; - gPrefs.persist("user", "name", name) ; - - var email = CY.get("#"+gNewReply['ids']['emailInputId']).get('value') ; - gPrefs.persist("user", "email", email) ; - } - - gSync.saveComment(gNewReply['ids']['formId']) ; + if (!sv_loggedIn) { + var name = CY.get("#"+gNewReply['ids']['nameInputId']).get('value') ; + gPrefs.persist("user", "name", name) ; + + var email = CY.get("#"+gNewReply['ids']['emailInputId']).get('value') ; + gPrefs.persist("user", "email", email) ; + } + + gSync.saveComment(gNewReply['ids']['formId']) ; } onCancelNewReplyClick = function() { - gSync.cancelReply() ; + gSync.cancelReply() ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_scopes.js --- a/src/cm/media/js/client/c_scopes.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_scopes.js Tue Nov 30 09:53:35 2010 +0100 @@ -7,52 +7,52 @@ // c-c is a comment marker paintCommentScope = function(comment) { - if (comment.reply_to_id == null && comment['start_wrapper'] != -1) { - var selection = { 'start' : { 'elt' : document.getElementById("sv_"+comment['start_wrapper']), 'offset' : comment['start_offset'] }, - 'end' : { 'elt' : document.getElementById("sv_"+comment['end_wrapper']), 'offset' : comment['end_offset'] } - } ; - if (document.getElementById("sv_"+comment['start_wrapper'])== null) { - warn_server({'from':'paintCommentScope', 'start_wrapper':comment['start_wrapper']}) ; - } - else { - if (document.getElementById("sv_"+comment['end_wrapper'])== null) - warn_server({'from':'paintCommentScope', 'end_wrapper':comment['end_wrapper']}) ; - else { - selection['start'] = _convertSelectionFromCSToCC(selection['start']) ; - selection['end'] = _convertSelectionFromCSToCC(selection['end']) ; - - renderComment(selection, comment['id']) ; - } - } - } + if (comment.reply_to_id == null && comment['start_wrapper'] != -1) { + var selection = { 'start' : { 'elt' : document.getElementById("sv_"+comment['start_wrapper']), 'offset' : comment['start_offset'] }, + 'end' : { 'elt' : document.getElementById("sv_"+comment['end_wrapper']), 'offset' : comment['end_offset'] } + } ; + if (document.getElementById("sv_"+comment['start_wrapper'])== null) { + warn_server({'from':'paintCommentScope', 'start_wrapper':comment['start_wrapper']}) ; + } + else { + if (document.getElementById("sv_"+comment['end_wrapper'])== null) + warn_server({'from':'paintCommentScope', 'end_wrapper':comment['end_wrapper']}) ; + else { + selection['start'] = _convertSelectionFromCSToCC(selection['start']) ; + selection['end'] = _convertSelectionFromCSToCC(selection['end']) ; + + renderComment(selection, comment['id']) ; + } + } + } } ; getCommentIdsFromClasses = function (elt) { - var commentIds = [] ; - var classes = elt['className'].split(" ") ; - for (var i = 0, ilen = classes.length ; i < ilen ; i++) { - if (classes[i].indexOf('c-id-') == 0) { - commentIds.push(parseInt(classes[i].substring('c-id-'.length))) ; - } - } - return commentIds ; + var commentIds = [] ; + var classes = elt['className'].split(" ") ; + for (var i = 0, ilen = classes.length ; i < ilen ; i++) { + if (classes[i].indexOf('c-id-') == 0) { + commentIds.push(parseInt(classes[i].substring('c-id-'.length))) ; + } + } + return commentIds ; } ; renderComment = function (selection, commentId) { - var startOffset = selection['start']['offset'] ; - var endOffset = selection['end']['offset'] ; - var startElt = selection['start']['elt'] ; - var endElt = selection['end']['elt'] ; + var startOffset = selection['start']['offset'] ; + var endOffset = selection['end']['offset'] ; + var startElt = selection['start']['elt'] ; + var endElt = selection['end']['elt'] ; - + if ((startElt != null) && (endElt != null) && _getTextNodeContent(startElt) != '' && _getTextNodeContent(endElt) != ''){ // log('startElt.id : ' + startElt.id) ; // log('endElt.id : ' + endElt.id) ; -// log('startElt.innerHTML : ' + startElt.innerHTML) ; -// log('endElt.innerHTML : ' + endElt.innerHTML) ; - markWholeNodesAsComments(startElt, endElt, commentId) ; - markEndsAsComments(startElt, startOffset, endElt, endOffset, commentId) ; - } +// log('startElt.innerHTML : ' + startElt.innerHTML) ; +// log('endElt.innerHTML : ' + endElt.innerHTML) ; + markWholeNodesAsComments(startElt, endElt, commentId) ; + markEndsAsComments(startElt, startOffset, endElt, endOffset, commentId) ; + } } ; markWholeNodesAsComments = function (startElt, endElt, commentId) { @@ -73,107 +73,107 @@ } ; markEndsAsComments = function(startElt, startOffset, endElt, endOffset, commentId) { - -// alert('starting with: ' + startElt.childNodes.length + 'and a length of : ' + startElt.firstChild.data.length) ; -// alert('2 and a length of : ' + CY.DOM.getText(startElt).length) ; + +// alert('starting with: ' + startElt.childNodes.length + 'and a length of : ' + startElt.firstChild.data.length) ; +// alert('2 and a length of : ' + CY.DOM.getText(startElt).length) ; - var beforeStart = _getTextNodeContent(startElt).substring(0, startOffset) ; - var afterStart = _getTextNodeContent(startElt).substring(startOffset) ; - var beforeEnd = _getTextNodeContent(endElt).substring(0, endOffset) ; - var afterEnd = _getTextNodeContent(endElt).substring(endOffset) ; + var beforeStart = _getTextNodeContent(startElt).substring(0, startOffset) ; + var afterStart = _getTextNodeContent(startElt).substring(startOffset) ; + var beforeEnd = _getTextNodeContent(endElt).substring(0, endOffset) ; + var afterEnd = _getTextNodeContent(endElt).substring(endOffset) ; var sameNode = (startElt === endElt) ; // log('beforeStart : ' + beforeStart + ' , afterStart : ' + afterStart + ' , beforeEnd : ' + beforeEnd + ' , afterEnd : ' + afterEnd + ' , sameNode : ' + sameNode) ; // taking care of start node : (and 'sameNode' case when start and end lie - // on same node) + // on same node) if (afterStart != "") { // otherwise nothing to do on the start node - if (CY.DOM.hasClass(startElt, 'c-c')) { - var lastElt = null, afterStartElt = null, afterEndElt = null, beforeStartElt = null ; - - var btw = (sameNode) ? _getTextNodeContent(startElt).substring(startOffset, endOffset) : afterStart ; - + if (CY.DOM.hasClass(startElt, 'c-c')) { + var lastElt = null, afterStartElt = null, afterEndElt = null, beforeStartElt = null ; + + var btw = (sameNode) ? _getTextNodeContent(startElt).substring(startOffset, endOffset) : afterStart ; + - if (sameNode && (afterEnd != "")) { - afterEndElt = startElt ; - lastElt = afterEndElt ; - } - if (btw != "") { - if (lastElt == null) { - afterStartElt = startElt ; - } - else { - afterStartElt = _yuiCloneNode(startElt) ; - lastElt.parentNode.insertBefore(afterStartElt, lastElt) ; - } - lastElt = afterStartElt ; - } - if (beforeStart != "") { - if (lastElt == null) { - beforeStartElt = startElt ; - } - else { - beforeStartElt = _yuiCloneNode(startElt) ; - lastElt.parentNode.insertBefore(beforeStartElt, lastElt) ; - } - lastElt = beforeStartElt ; - } - - if (afterEndElt != null) { - _setTextNodeContent(afterEndElt, afterEnd) ; - } - - if (afterStartElt != null) { - _setTextNodeContent(afterStartElt, btw) ; - _addIdClass(afterStartElt, commentId) ; - } + if (sameNode && (afterEnd != "")) { + afterEndElt = startElt ; + lastElt = afterEndElt ; + } + if (btw != "") { + if (lastElt == null) { + afterStartElt = startElt ; + } + else { + afterStartElt = _yuiCloneNode(startElt) ; + lastElt.parentNode.insertBefore(afterStartElt, lastElt) ; + } + lastElt = afterStartElt ; + } + if (beforeStart != "") { + if (lastElt == null) { + beforeStartElt = startElt ; + } + else { + beforeStartElt = _yuiCloneNode(startElt) ; + lastElt.parentNode.insertBefore(beforeStartElt, lastElt) ; + } + lastElt = beforeStartElt ; + } + + if (afterEndElt != null) { + _setTextNodeContent(afterEndElt, afterEnd) ; + } + + if (afterStartElt != null) { + _setTextNodeContent(afterStartElt, btw) ; + _addIdClass(afterStartElt, commentId) ; + } -// alert('beforeStartElt.firstChild.data.length: ' + beforeStartElt.firstChild.data.length); -// alert('beforeStartElt.childNodes.length: ' + beforeStartElt.childNodes.length); - if (beforeStartElt != null) { - _setTextNodeContent(beforeStartElt, beforeStart) ; - } -// alert('beforeStartElt.childNodes.length: ' + beforeStartElt.childNodes.length); - //alert('typeof beforeStartElt: ' + typeof beforeStartElt); -// alert('beforeStartElt.lastChild == beforeStartElt.firstChild : ' + (beforeStartElt.lastChild == beforeStartElt.firstChild)); - -// alert('beforeStartElt.firstChild.id : ' + beforeStartElt.firstChild.id); -// alert('beforeStartElt.lastChild.data : ' + beforeStartElt.lastChild.data); -// alert('beforeStartElt.firstChild.data : ' + beforeStartElt.firstChild.data); -// alert('afterStartElt.firstChild.data : ' + afterStartElt.firstChild.data); -// alert('afterEndElt.firstChild.data : ' + afterEndElt.firstChild.data); - - } +// alert('beforeStartElt.firstChild.data.length: ' + beforeStartElt.firstChild.data.length); +// alert('beforeStartElt.childNodes.length: ' + beforeStartElt.childNodes.length); + if (beforeStartElt != null) { + _setTextNodeContent(beforeStartElt, beforeStart) ; + } +// alert('beforeStartElt.childNodes.length: ' + beforeStartElt.childNodes.length); + //alert('typeof beforeStartElt: ' + typeof beforeStartElt); +// alert('beforeStartElt.lastChild == beforeStartElt.firstChild : ' + (beforeStartElt.lastChild == beforeStartElt.firstChild)); + +// alert('beforeStartElt.firstChild.id : ' + beforeStartElt.firstChild.id); +// alert('beforeStartElt.lastChild.data : ' + beforeStartElt.lastChild.data); +// alert('beforeStartElt.firstChild.data : ' + beforeStartElt.firstChild.data); +// alert('afterStartElt.firstChild.data : ' + afterStartElt.firstChild.data); +// alert('afterEndElt.firstChild.data : ' + afterEndElt.firstChild.data); + + } } if ( ( !sameNode ) && ( beforeEnd != "" ) ) { // otherwise nothing to do - // on the end node - if (CY.DOM.hasClass(endElt, 'c-c')) { - var lastElt = null, beforeEndElt = null, afterEndElt = null ; - - if (afterEnd != "") { - afterEndElt = endElt ; - lastElt = endElt ; - } - - if (beforeEnd != "") { - if (lastElt == null) - beforeEndElt = endElt ; - else { - beforeEndElt = _yuiCloneNode(endElt) ; - lastElt.parentNode.insertBefore(beforeEndElt, lastElt) ; - } - lastElt = beforeEndElt ; - } - if (afterEndElt != null) { - _setTextNodeContent(afterEndElt, afterEnd) ; - } - - if (beforeEndElt != null) { - _addIdClass(beforeEndElt, commentId) ; - _setTextNodeContent(beforeEndElt, beforeEnd) ; - } - } + // on the end node + if (CY.DOM.hasClass(endElt, 'c-c')) { + var lastElt = null, beforeEndElt = null, afterEndElt = null ; + + if (afterEnd != "") { + afterEndElt = endElt ; + lastElt = endElt ; + } + + if (beforeEnd != "") { + if (lastElt == null) + beforeEndElt = endElt ; + else { + beforeEndElt = _yuiCloneNode(endElt) ; + lastElt.parentNode.insertBefore(beforeEndElt, lastElt) ; + } + lastElt = beforeEndElt ; + } + if (afterEndElt != null) { + _setTextNodeContent(afterEndElt, afterEnd) ; + } + + if (beforeEndElt != null) { + _addIdClass(beforeEndElt, commentId) ; + _setTextNodeContent(beforeEndElt, beforeEnd) ; + } + } } } ; @@ -185,9 +185,9 @@ // was replaced with : // afterStartElt = _yuiCloneNode(startElt) ; _yuiCloneNode = function (srcElt) { - var ret = CY.Node.getDOMNode(CY.get('#'+srcElt.id).cloneNode(true)) ; - ret.id = CY.guid(); - return ret ; + var ret = CY.Node.getDOMNode(CY.get('#'+srcElt.id).cloneNode(true)) ; + ret.id = CY.guid(); + return ret ; } ; // will wrap textNodes into c-c spans going up the DOM tree from elt to ancestor @@ -201,55 +201,55 @@ // prev : will spannify previous siblings if true, next siblings otherwise _dynSpanToAnc = function (elt, ancestor, commentId, prev) { // log('in : _dynSpanToAnc, elt : ' + elt.id) ; - var c = elt ; + var c = elt ; while ((c != null) && (c !== ancestor) && (c.parentNode !== ancestor)) { - var c_sib = null ; - if (prev) { - c_sib = c.previousSibling ; - } - else { - c_sib = c.nextSibling ; - } - - if (c_sib == null) { - c = c.parentNode ; - } - else { - c = c_sib ; - _recAddComment(c, commentId) ; - } - } ; + var c_sib = null ; + if (prev) { + c_sib = c.previousSibling ; + } + else { + c_sib = c.nextSibling ; + } + + if (c_sib == null) { + c = c.parentNode ; + } + else { + c = c_sib ; + _recAddComment(c, commentId) ; + } + } ; } ; // between elt1 and elt2 (which are excluded) _dynSpanInBetween = function (anc, elt1, elt2, commentId) { - var a = elt1 ; - var elt1Anc = null ; + var a = elt1 ; + var elt1Anc = null ; while (a) { if (a.parentNode === anc) { - elt1Anc = a ; - break; + elt1Anc = a ; + break; } a = a.parentNode; } - if (elt1Anc != null) { - a = elt2 ; - var elt2Anc = null ; - while (a) { - if (a.parentNode === anc) { - elt2Anc = a ; - break; - } - a = a.parentNode; - } - if (elt2Anc != null) { // found both ancestor, now doing the work - a = elt1Anc.nextSibling ; - while ((a != null) && (a !== elt2Anc)) { - _recAddComment(a, commentId) ; - a = a.nextSibling ; - } - } - } + if (elt1Anc != null) { + a = elt2 ; + var elt2Anc = null ; + while (a) { + if (a.parentNode === anc) { + elt2Anc = a ; + break; + } + a = a.parentNode; + } + if (elt2Anc != null) { // found both ancestor, now doing the work + a = elt1Anc.nextSibling ; + while ((a != null) && (a !== elt2Anc)) { + _recAddComment(a, commentId) ; + a = a.nextSibling ; + } + } + } } ; // (copied from YUI dom-base) @@ -265,32 +265,32 @@ //elt is supposed to be c-c classed _addIdClass = function (elt, commentId) { - CY.DOM.addClass(elt, 'c-id-' + commentId) ; - _updateCommentCounter(elt) ; + CY.DOM.addClass(elt, 'c-id-' + commentId) ; + _updateCommentCounter(elt) ; } ; //elt is supposed to be c-c classed _removeIdClass = function (elt, commentId) { - CY.DOM.removeClass(elt, 'c-id-' + commentId) ; - _updateCommentCounter(elt) ; + CY.DOM.removeClass(elt, 'c-id-' + commentId) ; + _updateCommentCounter(elt) ; } ; //elt is supposed to be c-c classed _removeIdClasses = function (elt) { - var re = _cgetRegExp('(?:^|\\s+)c-id-(?:\\d+)', 'g'); - elt['className'] = elt['className'].replace(re, " ") ; - _updateCommentCounter(elt) ; + var re = _cgetRegExp('(?:^|\\s+)c-id-(?:\\d+)', 'g'); + elt['className'] = elt['className'].replace(re, " ") ; + _updateCommentCounter(elt) ; } ; _recAddComment = function (elt, commentId) { - if (CY.DOM.hasClass(elt, 'c-c')) { - _addIdClass(elt, commentId) ; - } - else { - var c = elt.firstChild ; + if (CY.DOM.hasClass(elt, 'c-c')) { + _addIdClass(elt, commentId) ; + } + else { + var c = elt.firstChild ; while (c != null) { - _recAddComment(c, commentId) ; - c = c.nextSibling ; + _recAddComment(c, commentId) ; + c = c.nextSibling ; } } } ; @@ -298,15 +298,15 @@ // might be expensive ... (? maybe should use contains when available, instead // of custom _bruteContains) _findCommonAncestor = function (elt1, elt2) { - if (_bruteContains(elt1, elt2)) - return elt1 ; - else { - var e = elt2 ; - while ((e != null) && !_bruteContains(e, elt1)) { - e = e.parentNode ; - } - return e ; - } + if (_bruteContains(elt1, elt2)) + return elt1 ; + else { + var e = elt2 ; + while ((e != null) && !_bruteContains(e, elt1)) { + e = e.parentNode ; + } + return e ; + } } ; _cregexCache = {} ; @@ -322,45 +322,45 @@ //c-c should be classed with a c-count-x where x is a number for color graduation //c-c should be classed with many c-id-xid where xid is the comment db id of comment that apply to it _updateCommentCounter = function (elt) { - var re = _cgetRegExp('(?:^|\\s+)c-id-(?:\\d+)', 'g'); - var matches = elt['className'].match(re); - var countIds = (matches == null) ? 0 : matches.length ; - - re = _cgetRegExp('(?:^|\\s+)c-count-(?:\\d+)', 'g'); - elt['className'] = elt['className'].replace(re, " ") ; - CY.DOM.addClass(elt, 'c-count-'+countIds+' ') ; + var re = _cgetRegExp('(?:^|\\s+)c-id-(?:\\d+)', 'g'); + var matches = elt['className'].match(re); + var countIds = (matches == null) ? 0 : matches.length ; + + re = _cgetRegExp('(?:^|\\s+)c-count-(?:\\d+)', 'g'); + elt['className'] = elt['className'].replace(re, " ") ; + CY.DOM.addClass(elt, 'c-count-'+countIds+' ') ; } ; _convertSelectionFromCCToCS = function (sel) { - var offset = sel['offset'] ; - var elt = sel['elt'].parentNode ; - - var e = sel['elt'].previousSibling ; - while (e != null) { - offset += _getTextNodeContent(e).length ; - e = e.previousSibling ; // will be a c-c !! - } - - return {'elt':elt, 'offset':offset} ; + var offset = sel['offset'] ; + var elt = sel['elt'].parentNode ; + + var e = sel['elt'].previousSibling ; + while (e != null) { + offset += _getTextNodeContent(e).length ; + e = e.previousSibling ; // will be a c-c !! + } + + return {'elt':elt, 'offset':offset} ; } ; _convertSelectionFromCSToCC = function (sel) { - var ret = {'elt':null, 'offset':-1} ; - - var cc = null ; - var ccElt = sel['elt'].firstChild ; - var length = 0 ; - while (ccElt != null) { - var prevLength = length ; - length += _getTextNodeContent(ccElt).length ; - if (length >= sel['offset']) { - ret['elt'] = ccElt ; - ret['offset'] = sel['offset'] - prevLength ; - break ; - } - ccElt = ccElt.nextSibling ; // will be a c-c !! - } - return ret ; + var ret = {'elt':null, 'offset':-1} ; + + var cc = null ; + var ccElt = sel['elt'].firstChild ; + var length = 0 ; + while (ccElt != null) { + var prevLength = length ; + length += _getTextNodeContent(ccElt).length ; + if (length >= sel['offset']) { + ret['elt'] = ccElt ; + ret['offset'] = sel['offset'] - prevLength ; + break ; + } + ccElt = ccElt.nextSibling ; // will be a c-c !! + } + return ret ; } ; @@ -371,89 +371,89 @@ unpaintCommentScope = function(comment) { var dbId = comment.id; - var classeId = 'c-id-' + dbId ; - var toBeRemovedElts = [] ; + var classeId = 'c-id-' + dbId ; + var toBeRemovedElts = [] ; - var cNodeList = CY.all("."+classeId) ; - if (cNodeList != null) { // null in case of a reply ... - for (var i = 0, ilen = cNodeList.size() ; i < ilen ; i++) { - var c = cNodeList.item(i) ; - if (c.hasClass('c-c')) { // always will !! - var cElt = CY.Node.getDOMNode(c) ; - _removeIdClass(cElt, dbId) ; - - var cIds = getCommentIdsFromClasses(cElt) ; - quicksort(cIds) ; - - var p = c.get('previousSibling') ; - if (p != null) { - var pElt = CY.Node.getDOMNode(p) ; - var pIds = getCommentIdsFromClasses(pElt) ; - quicksort(pIds) ; - if (areSortedArraysEqual(cIds, pIds)) { - _setTextNodeContent(cElt, _getTextNodeContent(pElt) + _getTextNodeContent(cElt)) ; - toBeRemovedElts.push(pElt) ; - } - } - - var n = c.get('nextSibling') ; - if (n != null) { - var nElt = CY.Node.getDOMNode(n) ; - var nIds = getCommentIdsFromClasses(nElt) ; - quicksort(nIds) ; - if (areSortedArraysEqual(cIds, nIds)) { - cElt.firstChild.data = cElt.firstChild.data + nElt.firstChild.data; - toBeRemovedElts.push(nElt) ; - } - } - } - else { - alert('HAS NO c-c ? : ' + commentNode.get('id') + " , innerHTML :" + commentNode.get('innerHTML')) ; - return ; - } - } - } - for (var i = 0, ilen = toBeRemovedElts.length ; i < ilen ; i++) { - toBeRemovedElts[i].parentNode.removeChild(toBeRemovedElts[i]) ; - } + var cNodeList = CY.all("."+classeId) ; + if (cNodeList != null) { // null in case of a reply ... + for (var i = 0, ilen = cNodeList.size() ; i < ilen ; i++) { + var c = cNodeList.item(i) ; + if (c.hasClass('c-c')) { // always will !! + var cElt = CY.Node.getDOMNode(c) ; + _removeIdClass(cElt, dbId) ; + + var cIds = getCommentIdsFromClasses(cElt) ; + quicksort(cIds) ; + + var p = c.get('previousSibling') ; + if (p != null) { + var pElt = CY.Node.getDOMNode(p) ; + var pIds = getCommentIdsFromClasses(pElt) ; + quicksort(pIds) ; + if (areSortedArraysEqual(cIds, pIds)) { + _setTextNodeContent(cElt, _getTextNodeContent(pElt) + _getTextNodeContent(cElt)) ; + toBeRemovedElts.push(pElt) ; + } + } + + var n = c.get('nextSibling') ; + if (n != null) { + var nElt = CY.Node.getDOMNode(n) ; + var nIds = getCommentIdsFromClasses(nElt) ; + quicksort(nIds) ; + if (areSortedArraysEqual(cIds, nIds)) { + cElt.firstChild.data = cElt.firstChild.data + nElt.firstChild.data; + toBeRemovedElts.push(nElt) ; + } + } + } + else { + alert('HAS NO c-c ? : ' + commentNode.get('id') + " , innerHTML :" + commentNode.get('innerHTML')) ; + return ; + } + } + } + for (var i = 0, ilen = toBeRemovedElts.length ; i < ilen ; i++) { + toBeRemovedElts[i].parentNode.removeChild(toBeRemovedElts[i]) ; + } } ; // not related to the unpaintCommentScope function (faster) unpaintAllComments = function() { - var cNodeList= CY.all(".c-s") ; - var toBeRemovedElts = [] ; - for (var i = 0, ilen = cNodeList.size() ; i < ilen ; i++) { - var c = cNodeList.item(i) ; - - // remove Classes - var fc = c.get('firstChild') ; - var fcElt = CY.Node.getDOMNode(c.get('firstChild')) ; - _removeIdClasses(fcElt) ; - - // merge nodes - var n = fc.get('nextSibling') ; - while (n != null)  { - var nElt = CY.Node.getDOMNode(n) ; - fcElt.firstChild.data = fcElt.firstChild.data + nElt.firstChild.data; - toBeRemovedElts.push(nElt) ; - n = n.get('nextSibling') ; - } - } - for (var i = 0, ilen = toBeRemovedElts.length ; i < ilen ; i++) { - toBeRemovedElts[i].parentNode.removeChild(toBeRemovedElts[i]) ; - } + var cNodeList= CY.all(".c-s") ; + var toBeRemovedElts = [] ; + for (var i = 0, ilen = cNodeList.size() ; i < ilen ; i++) { + var c = cNodeList.item(i) ; + + // remove Classes + var fc = c.get('firstChild') ; + var fcElt = CY.Node.getDOMNode(c.get('firstChild')) ; + _removeIdClasses(fcElt) ; + + // merge nodes + var n = fc.get('nextSibling') ; + while (n != null)  { + var nElt = CY.Node.getDOMNode(n) ; + fcElt.firstChild.data = fcElt.firstChild.data + nElt.firstChild.data; + toBeRemovedElts.push(nElt) ; + n = n.get('nextSibling') ; + } + } + for (var i = 0, ilen = toBeRemovedElts.length ; i < ilen ; i++) { + toBeRemovedElts[i].parentNode.removeChild(toBeRemovedElts[i]) ; + } } ; showScope = function(commentDbId) { - var s = CY.all('.c-id-' + commentDbId); - if (s != null) - s.addClass('c-scope') ; + var s = CY.all('.c-id-' + commentDbId); + if (s != null) + s.addClass('c-scope') ; } ; hideScopeAnyway = function() { - var s = CY.all('.c-scope'); - if (s != null) - s.removeClass('c-scope') ; + var s = CY.all('.c-scope'); + if (s != null) + s.removeClass('c-scope') ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_selection.js --- a/src/cm/media/js/client/c_selection.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_selection.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,22 +1,22 @@ getWrapperAncestor = function(elt) { - var parent = elt ; - while (parent != null) { - if (CY.DOM.hasClass(parent, 'c-s')) - return parent ; - parent = parent.parentNode ; - } - return null ; + var parent = elt ; + while (parent != null) { + if (CY.DOM.hasClass(parent, 'c-s')) + return parent ; + parent = parent.parentNode ; + } + return null ; } hasWrapperAncestor = function(elt) { - return (getWrapperAncestor(elt) != null) ; -/* var parent = elt ; - while (parent != null) { - if (CY.DOM.hasClass(parent, 'c-s')) - return true ; - parent = parent.parentNode ; - } - return false ;*/ + return (getWrapperAncestor(elt) != null) ; +/* var parent = elt ; + while (parent != null) { + if (CY.DOM.hasClass(parent, 'c-s')) + return true ; + parent = parent.parentNode ; + } + return false ;*/ } // returns null or : @@ -27,173 +27,173 @@ // when selection starts/ends in/on a non textual element (
for example) we very often have anchorNode/focusNode == body elt // TODO adapt this body case by considering offset ( cf. http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html) getSelectionInfo = function () { - var startNode = null, endNode = null, startOffset = 0, endOffset = 0, text = '' ; - - if (window.getSelection) { // everything else than IE - var userSelection = window.getSelection(); + var startNode = null, endNode = null, startOffset = 0, endOffset = 0, text = '' ; + + if (window.getSelection) { // everything else than IE + var userSelection = window.getSelection(); - if (userSelection.rangeCount > 0) { - var range = userSelection.getRangeAt(0) ; - text = range.toString() ; - if (text != "")  { - - // selection occured from right to left ? : - var r1 = document.createRange() ;r1.setStart(userSelection.anchorNode, userSelection.anchorOffset) ;r1.collapse(true) ; - var r2 = document.createRange() ;r2.setEnd(userSelection.focusNode, userSelection.focusOffset) ;r2.collapse(false) ; - var leftToRight = (r2.compareBoundaryPoints(2, r1) == 1) ; // 2 is for END_TO_END -// CY.log("leftToRight : " + leftToRight) ; - startNode = (leftToRight) ? userSelection.anchorNode.parentNode : userSelection.focusNode.parentNode ; - innerStartNode = (leftToRight) ? userSelection.anchorNode : userSelection.focusNode ; - endNode = (leftToRight) ? userSelection.focusNode.parentNode : userSelection.anchorNode.parentNode; - innerEndNode = (leftToRight) ? userSelection.focusNode : userSelection.anchorNode; - - startOffset = (leftToRight) ? userSelection.anchorOffset : userSelection.focusOffset; - endOffset = (leftToRight) ? userSelection.focusOffset : userSelection.anchorOffset ; + if (userSelection.rangeCount > 0) { + var range = userSelection.getRangeAt(0) ; + text = range.toString() ; + if (text != "")  { + + // selection occured from right to left ? : + var r1 = document.createRange() ;r1.setStart(userSelection.anchorNode, userSelection.anchorOffset) ;r1.collapse(true) ; + var r2 = document.createRange() ;r2.setEnd(userSelection.focusNode, userSelection.focusOffset) ;r2.collapse(false) ; + var leftToRight = (r2.compareBoundaryPoints(2, r1) == 1) ; // 2 is for END_TO_END +// CY.log("leftToRight : " + leftToRight) ; + startNode = (leftToRight) ? userSelection.anchorNode.parentNode : userSelection.focusNode.parentNode ; + innerStartNode = (leftToRight) ? userSelection.anchorNode : userSelection.focusNode ; + endNode = (leftToRight) ? userSelection.focusNode.parentNode : userSelection.anchorNode.parentNode; + innerEndNode = (leftToRight) ? userSelection.focusNode : userSelection.anchorNode; + + startOffset = (leftToRight) ? userSelection.anchorOffset : userSelection.focusOffset; + endOffset = (leftToRight) ? userSelection.focusOffset : userSelection.anchorOffset ; - if (!hasWrapperAncestor(endNode) && hasWrapperAncestor(startNode)){ - var r3 = document.createRange() ; - r3.setStart(innerStartNode, startOffset) ; + if (!hasWrapperAncestor(endNode) && hasWrapperAncestor(startNode)){ + var r3 = document.createRange() ; + r3.setStart(innerStartNode, startOffset) ; - var csStartAncestor = getWrapperAncestor(startNode) ; - var next = csStartAncestor ; - r3.setEndAfter(next) ; - - var ind = parseInt(csStartAncestor.id.substring('sv_'.length)) ; - while(r3.toString().length < range.toString().length) { - ind++ ; - var node = CY.get("#sv_"+ind) ; - if (node) { - next = CY.Node.getDOMNode(node) ; - r3.setEndAfter(next) ; - } - else - break ; - } - endNode = next.lastChild ; - endOffset = CY.DOM.getText(endNode).length ; - } - else if (!hasWrapperAncestor(startNode) && hasWrapperAncestor(endNode)){ - var r3 = document.createRange() ; - r3.setEnd(innerEndNode, endOffset) ; + var csStartAncestor = getWrapperAncestor(startNode) ; + var next = csStartAncestor ; + r3.setEndAfter(next) ; + + var ind = parseInt(csStartAncestor.id.substring('sv_'.length)) ; + while(r3.toString().length < range.toString().length) { + ind++ ; + var node = CY.get("#sv_"+ind) ; + if (node) { + next = CY.Node.getDOMNode(node) ; + r3.setEndAfter(next) ; + } + else + break ; + } + endNode = next.lastChild ; + endOffset = CY.DOM.getText(endNode).length ; + } + else if (!hasWrapperAncestor(startNode) && hasWrapperAncestor(endNode)){ + var r3 = document.createRange() ; + r3.setEnd(innerEndNode, endOffset) ; - var csEndAncestor = getWrapperAncestor(endNode) ; - var prev = csEndAncestor ; - r3.setStartBefore(prev) ; - - var ind = parseInt(csEndAncestor.id.substring('sv_'.length)) ; - while(r3.toString().length < range.toString().length) { - ind-- ; - var node = CY.get("#sv_"+ind) ; - if (node) { - prev = CY.Node.getDOMNode(node) ; - r3.setStartBefore(prev) ; - } - else - break ; - } - startNode = prev.firstChild ; - startOffset = 0 ; - } - else if (!hasWrapperAncestor(startNode) && !hasWrapperAncestor(endNode)){ - var textLength = text.length ; - - // gather nodes with id sv_xxxx as candidates for start ancestor - var startNodeInds = [] ; - for (var ind = 0 ; ; ind++) { - var svNode = CY.get("#sv_"+ind) ; - if (svNode == null) { - break; - } - else { - var svText = svNode.get("text") ; - if (text.indexOf(svText) == 0) { - startNodeInds.push(ind) ; - } - } - } - - // gather nodes with id sv_xxxx as candidates for end ancestor - var endNodeInds = [] ; - for (var ind = 0 ; ; ind++) { - var svNode = CY.get("#sv_"+ind) ; - if (svNode == null) { - break; - } - else { - var svText = svNode.get("text") ; - if (text.indexOf(svText) == (textLength - svText.length)) { // i.e. the selection exactly ends with svText - endNodeInds.push(ind) ; - } - } - } + var csEndAncestor = getWrapperAncestor(endNode) ; + var prev = csEndAncestor ; + r3.setStartBefore(prev) ; + + var ind = parseInt(csEndAncestor.id.substring('sv_'.length)) ; + while(r3.toString().length < range.toString().length) { + ind-- ; + var node = CY.get("#sv_"+ind) ; + if (node) { + prev = CY.Node.getDOMNode(node) ; + r3.setStartBefore(prev) ; + } + else + break ; + } + startNode = prev.firstChild ; + startOffset = 0 ; + } + else if (!hasWrapperAncestor(startNode) && !hasWrapperAncestor(endNode)){ + var textLength = text.length ; + + // gather nodes with id sv_xxxx as candidates for start ancestor + var startNodeInds = [] ; + for (var ind = 0 ; ; ind++) { + var svNode = CY.get("#sv_"+ind) ; + if (svNode == null) { + break; + } + else { + var svText = svNode.get("text") ; + if (text.indexOf(svText) == 0) { + startNodeInds.push(ind) ; + } + } + } + + // gather nodes with id sv_xxxx as candidates for end ancestor + var endNodeInds = [] ; + for (var ind = 0 ; ; ind++) { + var svNode = CY.get("#sv_"+ind) ; + if (svNode == null) { + break; + } + else { + var svText = svNode.get("text") ; + if (text.indexOf(svText) == (textLength - svText.length)) { // i.e. the selection exactly ends with svText + endNodeInds.push(ind) ; + } + } + } - var stop = false ; - for (var i = 0 ; i < startNodeInds.length ; i++) { - for (var j = 0 ; j < endNodeInds.length ; j++) { - var r4 = document.createRange() ; - - var s = CY.Node.getDOMNode(CY.get("#sv_"+startNodeInds[i])) ; var e = CY.Node.getDOMNode(CY.get("#sv_"+endNodeInds[j])) ; - - r4.setStartBefore(s) ; r4.setEndAfter(CY.Node.getDOMNode(e)) ; - - // does r4 starts after range start and r4 ends before range end ? - if ((-1 < r4.compareBoundaryPoints(0, range)) && (1 > r4.compareBoundaryPoints(2, range))) { - startNode = s.firstChild ; - startOffset = 0 ; - endNode = e.lastChild ; - endOffset = CY.DOM.getText(e).length ; - - stop = true ; - break ; - } - } - if (stop) - break ; - } - } - - r1.detach() ; - r2.detach() ; - } - else - return null ; - } - else - return null ; - - } - else if (document.selection) { // IE case - var rng = document.selection.createRange(); - if (rng.text.length == 0) - return null ; - var el = rng.parentElement(); + var stop = false ; + for (var i = 0 ; i < startNodeInds.length ; i++) { + for (var j = 0 ; j < endNodeInds.length ; j++) { + var r4 = document.createRange() ; + + var s = CY.Node.getDOMNode(CY.get("#sv_"+startNodeInds[i])) ; var e = CY.Node.getDOMNode(CY.get("#sv_"+endNodeInds[j])) ; + + r4.setStartBefore(s) ; r4.setEndAfter(CY.Node.getDOMNode(e)) ; + + // does r4 starts after range start and r4 ends before range end ? + if ((-1 < r4.compareBoundaryPoints(0, range)) && (1 > r4.compareBoundaryPoints(2, range))) { + startNode = s.firstChild ; + startOffset = 0 ; + endNode = e.lastChild ; + endOffset = CY.DOM.getText(e).length ; + + stop = true ; + break ; + } + } + if (stop) + break ; + } + } + + r1.detach() ; + r2.detach() ; + } + else + return null ; + } + else + return null ; + + } + else if (document.selection) { // IE case + var rng = document.selection.createRange(); + if (rng.text.length == 0) + return null ; + var el = rng.parentElement(); - // duplicate the range and collapse it to its start, to ask IE the parent element of the start textNode. - var rngStart = rng.duplicate(); - var rngEnd = rng.duplicate(); + // duplicate the range and collapse it to its start, to ask IE the parent element of the start textNode. + var rngStart = rng.duplicate(); + var rngEnd = rng.duplicate(); - rngStart.collapse(true); // collapse to start - rngEnd.collapse(false); // collapse to end - - startNode = rngStart.parentElement() ; - while(rngStart.moveStart('character', -1) != 0) { - if (rngStart.parentElement() != startNode) - break ; - startOffset++ ; - } - endNode = rngEnd.parentElement() ; - while(rngEnd.moveEnd('character', -1) != 0) { - if (rngEnd.parentElement() != endNode) - break ; - endOffset++ ; - } - - text = rng.text ; - } - - if (!hasWrapperAncestor(startNode) || !hasWrapperAncestor(endNode)){ - // CY.log('no wrapper on one end') ; - return null ; - } - return {'text' : text, 'start' : {'elt':startNode, 'offset':startOffset}, 'end' : {'elt':endNode, 'offset':endOffset}} ; -} \ No newline at end of file + rngStart.collapse(true); // collapse to start + rngEnd.collapse(false); // collapse to end + + startNode = rngStart.parentElement() ; + while(rngStart.moveStart('character', -1) != 0) { + if (rngStart.parentElement() != startNode) + break ; + startOffset++ ; + } + endNode = rngEnd.parentElement() ; + while(rngEnd.moveEnd('character', -1) != 0) { + if (rngEnd.parentElement() != endNode) + break ; + endOffset++ ; + } + + text = rng.text ; + } + + if (!hasWrapperAncestor(startNode) || !hasWrapperAncestor(endNode)){ + // CY.log('no wrapper on one end') ; + return null ; + } + return {'text' : text, 'start' : {'elt':startNode, 'offset':startOffset}, 'end' : {'elt':endNode, 'offset':endOffset}} ; +} diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_server_exchange.js --- a/src/cm/media/js/client/c_server_exchange.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_server_exchange.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,84 +1,84 @@ //frames['text_view_comment_frames'].gtest.myFunc() var gtest = { - renaud : 'RENAUD', - random : Math.random(), - bernard : 'BERNARD', - myFunc : function() { - doExchange("theServerFun", {}, null, this.myRetFunc, this, ['foo', 'bar']) - }, - myRetFunc : function(args) { - CY.log('this.renaud : ' + this.renaud) ; - CY.log('this.random : ' + this.random) ; - CY.log('arg.returned : ' + args.returned) ; - CY.log(args.returned) ; - CY.log('arg.success : ' + args.success) ; - CY.log(args.success) ; - //CY.log('arg.success : ' + arg.success) ; - } + renaud : 'RENAUD', + random : Math.random(), + bernard : 'BERNARD', + myFunc : function() { + doExchange("theServerFun", {}, null, this.myRetFunc, this, ['foo', 'bar']) + }, + myRetFunc : function(args) { + CY.log('this.renaud : ' + this.renaud) ; + CY.log('this.random : ' + this.random) ; + CY.log('arg.returned : ' + args.returned) ; + CY.log(args.returned) ; + CY.log('arg.success : ' + args.success) ; + CY.log(args.success) ; + //CY.log('arg.success : ' + arg.success) ; + } } ; // clientArgs should be an array doExchange = function(serverFun, obj, formId, retFunc, clientContext, clientArgs, inCaseErrorMsg) { - obj['fun'] = serverFun ; - obj['key'] = sv_key ; - obj['version_key'] = sv_version_key ; -// obj['adminKey'] = sv_adminKey ; - - var cfg = { - method: "POST", - data: urlEncode(obj), -// headers: { 'X-Transaction': 'POST Example'}, - on: { -// start: gtH.start, -// complete: gtH.complete, - success: function(id, oResponse, args){ // args will be {success:clientArgs etc ... - var ret = {}; - if (oResponse.responseText) - ret = CY.JSON.parse(oResponse.responseText); - - if (gLayout.isInFrame() && ('msg' in ret)) - parent.f_enqueueMsg(ret['msg']) ; - - args['returned'] = ret ; - args['successfull'] = true ; - - retFunc.call(clientContext, args); - }, - failure: function(id, oResponse, args){ // args will be {success:clientArgs etc ... - if (gLayout.isInFrame()) - parent.f_enqueueErrorMsg(gettext('error:') + inCaseErrorMsg) ; - - args['successfull'] = false ; - retFunc.call(clientContext, args); - } - }, -// context: gtH, - arguments: { -// start: 'foo', -// complete: 'bar', - success: clientArgs, - failure: clientArgs - } - } ; - if (formId != null) - cfg['form'] = {'id':formId}; - CY.io(sv_client_url, cfg); - + obj['fun'] = serverFun ; + obj['key'] = sv_key ; + obj['version_key'] = sv_version_key ; +// obj['adminKey'] = sv_adminKey ; + + var cfg = { + method: "POST", + data: urlEncode(obj), +// headers: { 'X-Transaction': 'POST Example'}, + on: { +// start: gtH.start, +// complete: gtH.complete, + success: function(id, oResponse, args){ // args will be {success:clientArgs etc ... + var ret = {}; + if (oResponse.responseText) + ret = CY.JSON.parse(oResponse.responseText); + + if (gLayout.isInFrame() && ('msg' in ret)) + parent.f_enqueueMsg(ret['msg']) ; + + args['returned'] = ret ; + args['successfull'] = true ; + + retFunc.call(clientContext, args); + }, + failure: function(id, oResponse, args){ // args will be {success:clientArgs etc ... + if (gLayout.isInFrame()) + parent.f_enqueueErrorMsg(gettext('error:') + inCaseErrorMsg) ; + + args['successfull'] = false ; + retFunc.call(clientContext, args); + } + }, +// context: gtH, + arguments: { +// start: 'foo', +// complete: 'bar', + success: clientArgs, + failure: clientArgs + } + } ; + if (formId != null) + cfg['form'] = {'id':formId}; + CY.io(sv_client_url, cfg); + } ; // TODO try to get a stack trace instead of passing an obj warn_server = function(obj) { - obj['fun'] = "warn" ; - obj['key'] = sv_key ; - obj['version_key'] = sv_version_key ; + obj['fun'] = "warn" ; + obj['key'] = sv_key ; + obj['version_key'] = sv_version_key ; - var obj2 = CY.UA ; + var obj2 = CY.UA ; - var cfg = { - method: "POST", - data: urlEncode(CY.merge(obj, obj2)) - } ; - CY.io('/client/', cfg); + var cfg = { + method: "POST", + data: urlEncode(CY.merge(obj, obj2)) + } ; + CY.io('/client/', cfg); } ; diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_sync.js --- a/src/cm/media/js/client/c_sync.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_sync.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,548 +1,548 @@ gShowingAllComments = false ; // YUI : queue, overlay Sync = function() { - // this queue handles both animations and io requests - this._q = null ; - - this._iPreventClick = false ; // oh really ? + // this queue handles both animations and io requests + this._q = null ; + + this._iPreventClick = false ; // oh really ? } Sync.prototype = { - init : function (iComment) { - this._q = new CY.AsyncQueue() ; + init : function (iComment) { + this._q = new CY.AsyncQueue() ; // pr2 this._q = new CY.Queue() ; - }, - - setPreventClickOn : function () { - CY.log("setPreventClickOn !") ; - if (gLayout.isInFrame()) - parent.f_interfaceFreeze() - this._iPreventClick = true ; - }, + }, + + setPreventClickOn : function () { + CY.log("setPreventClickOn !") ; + if (gLayout.isInFrame()) + parent.f_interfaceFreeze() + this._iPreventClick = true ; + }, - setPreventClickOff : function () { - CY.log("setPreventClickOff !") ; - if (gLayout.isInFrame()) - parent.f_interfaceUnfreeze() - this._iPreventClick = false ; - }, + setPreventClickOff : function () { + CY.log("setPreventClickOff !") ; + if (gLayout.isInFrame()) + parent.f_interfaceUnfreeze() + this._iPreventClick = false ; + }, - removeCommentRet : function(args) { - var successfull = args['successfull'] ; - - var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; - - if (successfull) { - var filterData = args['returned']['filterData'] ; - if (gLayout.isInFrame()) { - parent.f_updateFilterData(filterData) ; - } - - var y = gIComments.getTopPosition()[1] ; - - var comment = gDb.getComment(iComment.commentId) ; - this._q.add( - function(){ - - unpaintCommentScope(comment) ; - gIComments.close(comment.id) ; - gIComments.remove(comment.id) ; - if (comment.reply_to_id != null) - gIComments.refresh(comment.reply_to_id) ; - - gDb.del(comment) ; - - if (gLayout.isInFrame()) { - if (gDb.comments.length == 0 && gDb.allComments.length != 0) { - parent.f_enqueueMsg(gettext("no filtered comments left")) ; - parent.resetFilter() ; - } - else { - // just counting here ... - var filterRes = gDb.computeFilterResults() ; - updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']) ; - } - } - } - ); - - this._animateTo(y) ; - } - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this.resume() ; - }, - - moderateCommentRet : function(args) { - var successfull = args['successfull'] ; + removeCommentRet : function(args) { + var successfull = args['successfull'] ; + + var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; + + if (successfull) { + var filterData = args['returned']['filterData'] ; + if (gLayout.isInFrame()) { + parent.f_updateFilterData(filterData) ; + } + + var y = gIComments.getTopPosition()[1] ; + + var comment = gDb.getComment(iComment.commentId) ; + this._q.add( + function(){ + + unpaintCommentScope(comment) ; + gIComments.close(comment.id) ; + gIComments.remove(comment.id) ; + if (comment.reply_to_id != null) + gIComments.refresh(comment.reply_to_id) ; + + gDb.del(comment) ; + + if (gLayout.isInFrame()) { + if (gDb.comments.length == 0 && gDb.allComments.length != 0) { + parent.f_enqueueMsg(gettext("no filtered comments left")) ; + parent.resetFilter() ; + } + else { + // just counting here ... + var filterRes = gDb.computeFilterResults() ; + updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']) ; + } + } + } + ); + + this._animateTo(y) ; + } + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this.resume() ; + }, + + moderateCommentRet : function(args) { + var successfull = args['successfull'] ; - var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; + var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; - if (successfull) { - var ret = args['returned'] ; - var comment = ret['comment'] ; + if (successfull) { + var ret = args['returned'] ; + var comment = ret['comment'] ; - gDb.upd(comment) ; - - var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; - if (shouldReset){ - parent.resetFilter() ; - this._showSingleComment(comment) ; - } - else - iComment.changeModeration(comment) ; - } + gDb.upd(comment) ; + + var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; + if (shouldReset){ + parent.resetFilter() ; + this._showSingleComment(comment) ; + } + else + iComment.changeModeration(comment) ; + } - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this.resume() ; - }, - - saveCommentRet : function(args) { - var successfull = args['successfull'] ; - if (successfull) { - var formId = args['success']['formId'] ; - var ret = args['returned'] ; - - removeFormErrMsg(formId) ; - - if ('errors' in ret) { // validation error - var errors = ret['errors'] ; - for (var eltName in errors) { - addFormErrMsg(formId, eltName, errors[eltName]) ; - } - this._animateToTop() ; - } - else { - var isReply = function() {return (gNewReply != null) && (formId == gNewReply['ids']['formId']) ;} ; - var isNewComment = function() {return (gICommentForm != null) && (formId == gICommentForm['formId']) ;} ; - var isEdit = function() {return (gEdit != null) && (formId == gEdit['ids']['formId']) ;} ; - - // doing this here for the a priori moderation case - if (isNewComment()) - this.hideICommentForm(cleanICommentForm()) ; - else if (isEdit()) - this._hideEditForm() ; - else if (isReply()) - this._hideNewReplyForm() ; - - if ("ask_for_notification" in ret) { - if (ret['ask_for_notification']) { - // TODO ask for notification ...or use AUTO_CONTRIB ? - parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"), gettext("Reply notification"), - function() { // special case : no waiting for the return, no error check, nothing ! - var cfg = { - method: "POST", - data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':false}) - } ; - CY.io(sv_client_url, cfg); - }, this, null, - function() { // special case : no waiting for the return, no error check, nothing ! - var cfg = { - method: "POST", - data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':true}) - } ; - CY.io(sv_client_url, cfg); - }, this, null) ; - } - } - - - if ("comment" in ret) { // won't be when add with a priori moderation - var comment = ret['comment'] ; - - gDb.upd(comment) ; - - var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; - if (shouldReset) - parent.resetFilter() ; - else { // ASSUMING filter is in init state ! (because when not // TODO $$$$$$$$$$$ this isn't true anymore .... when passing filter arguments in url !! - // in frame for now data can't be filtered) - if (comment.reply_to_id == null) { // not a reply - unpaintCommentScope(comment) ; // for the edit case - paintCommentScope(comment) ; - } - } - - // UPDATE FILTER DATA // TODO move ???? - var filterData = ret['filterData'] ; - if (gLayout.isInFrame()) { - parent.f_updateFilterData(filterData) ; - updateResetFilterResultsCount() ; - } + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this.resume() ; + }, + + saveCommentRet : function(args) { + var successfull = args['successfull'] ; + if (successfull) { + var formId = args['success']['formId'] ; + var ret = args['returned'] ; + + removeFormErrMsg(formId) ; + + if ('errors' in ret) { // validation error + var errors = ret['errors'] ; + for (var eltName in errors) { + addFormErrMsg(formId, eltName, errors[eltName]) ; + } + this._animateToTop() ; + } + else { + var isReply = function() {return (gNewReply != null) && (formId == gNewReply['ids']['formId']) ;} ; + var isNewComment = function() {return (gICommentForm != null) && (formId == gICommentForm['formId']) ;} ; + var isEdit = function() {return (gEdit != null) && (formId == gEdit['ids']['formId']) ;} ; + + // doing this here for the a priori moderation case + if (isNewComment()) + this.hideICommentForm(cleanICommentForm()) ; + else if (isEdit()) + this._hideEditForm() ; + else if (isReply()) + this._hideNewReplyForm() ; + + if ("ask_for_notification" in ret) { + if (ret['ask_for_notification']) { + // TODO ask for notification ...or use AUTO_CONTRIB ? + parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"), gettext("Reply notification"), + function() { // special case : no waiting for the return, no error check, nothing ! + var cfg = { + method: "POST", + data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':false}) + } ; + CY.io(sv_client_url, cfg); + }, this, null, + function() { // special case : no waiting for the return, no error check, nothing ! + var cfg = { + method: "POST", + data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':true}) + } ; + CY.io(sv_client_url, cfg); + }, this, null) ; + } + } + + + if ("comment" in ret) { // won't be when add with a priori moderation + var comment = ret['comment'] ; + + gDb.upd(comment) ; + + var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; + if (shouldReset) + parent.resetFilter() ; + else { // ASSUMING filter is in init state ! (because when not // TODO $$$$$$$$$$$ this isn't true anymore .... when passing filter arguments in url !! + // in frame for now data can't be filtered) + if (comment.reply_to_id == null) { // not a reply + unpaintCommentScope(comment) ; // for the edit case + paintCommentScope(comment) ; + } + } + + // UPDATE FILTER DATA // TODO move ???? + var filterData = ret['filterData'] ; + if (gLayout.isInFrame()) { + parent.f_updateFilterData(filterData) ; + updateResetFilterResultsCount() ; + } - if (isReply()) { // add reply case - if (!shouldReset) { - this._insertReply(comment) ; - } - } - else { // edit (reply or comment) or add (comment) case - this._showSingleComment(comment) ; - } - } - else - this._animateToTop() ; - } + if (isReply()) { // add reply case + if (!shouldReset) { + this._insertReply(comment) ; + } + } + else { // edit (reply or comment) or add (comment) case + this._showSingleComment(comment) ; + } + } + else + this._animateToTop() ; + } - } - else { // TODO ? ALL ret-FUNCTIONS ? - this._q.add({id:"expl", fn:function () {CY.log('in example .........') ;}}) ; - this._q.promote("expl") ; - } + } + else { // TODO ? ALL ret-FUNCTIONS ? + this._q.add({id:"expl", fn:function () {CY.log('in example .........') ;}}) ; + this._q.promote("expl") ; + } - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this.resume() ; - }, - - example : function () { - CY.log('in example .........') ; - }, + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this.resume() ; + }, + + example : function () { + CY.log('in example .........') ; + }, - moderateComment : function(iComment, state) { - var comment = gDb.getComment(iComment['commentId']) ; + moderateComment : function(iComment, state) { + var comment = gDb.getComment(iComment['commentId']) ; this._q.add( - {fn:CY.bind(this.setPreventClickOn, this)}, - {autoContinue:false, fn:CY.bind(doExchange, null, "editComment", {'comment_key':comment.key, 'state':state}, null, this.moderateCommentRet, this, {'iComment':iComment}, gettext("could not save comment"))} - ).run(); - }, - - _saveComment : function(serverFun, formId) { + {fn:CY.bind(this.setPreventClickOn, this)}, + {autoContinue:false, fn:CY.bind(doExchange, null, "editComment", {'comment_key':comment.key, 'state':state}, null, this.moderateCommentRet, this, {'iComment':iComment}, gettext("could not save comment"))} + ).run(); + }, + + _saveComment : function(serverFun, formId) { this._q.add( - {fn:CY.bind(this.setPreventClickOn, this)}, - {autoContinue:false, fn:CY.bind(doExchange, null, serverFun, {}, formId, this.saveCommentRet, this, {'formId':formId}, gettext("could not save comment"))} - ).run(); - }, - - editComment : function() { - this._saveComment("editComment", gEdit['ids']['formId']) ; - }, - - saveComment : function(formId) { - this._saveComment("addComment", formId) ; - }, - - removeComment : function(iComment) { - checkForOpenedDialog(iComment, function() { - if (gLayout.isInFrame()) { - parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"), gettext("Warning"), function() { this.animateToTop() ;}, this, null, function() { - var comment = gDb.getComment(iComment.commentId) ; - this._q.add( - {fn:CY.bind(this.setPreventClickOn, this)}, - {autoContinue:false, fn:CY.bind(doExchange, null, "removeComment", {'comment_key':comment.key}, null, this.removeCommentRet, this, {'iComment':iComment}, gettext("could not remove comment"))} - ).run(); - }, this, null) ; - - } -// else { -// alert("TODO : can't yet delete comments when not embed in text_view_frame because can't 'dialog' confirmation") ; -// } - - }, this, null) ; - }, - - resume : function(commentDbIds, mouseXY) { - this._q.run() ; - }, - - resetAutoContinue : function(callbackId) { - this._q.getCallback(callbackId).autoContinue = true; - }, - - hideICommentForm : function(funObj) { -// this._q.add({fn:function() {persistICommentFormValues();}}) ; - this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationHide'].run, gICommentForm['animationHide'])}) ; -// this._q.add({fn:function() {cleanICommentForm();}}) ; - if (funObj) - this._q.add(funObj) ; - }, - - /* ANIMATION DRIVEN INTERFACE CHANGES */ - - showCommentForm : function(iComment) { - checkForOpenedDialog(null, function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() { - if (iComment == null) { - var selection = getSelectionInfo() ; - updateICommentFormSelection(selection) ; - } - showICommentForm(iComment); - }}) ; - this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationShow'].run, gICommentForm['animationShow'])}, - {fn:CY.bind(this.setPreventClickOff, this)} - ).run(); - }, this, null) ; - }, - - showEditForm : function(iComment) { - checkForOpenedDialog(null, function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); + {fn:CY.bind(this.setPreventClickOn, this)}, + {autoContinue:false, fn:CY.bind(doExchange, null, serverFun, {}, formId, this.saveCommentRet, this, {'formId':formId}, gettext("could not save comment"))} + ).run(); + }, + + editComment : function() { + this._saveComment("editComment", gEdit['ids']['formId']) ; + }, + + saveComment : function(formId) { + this._saveComment("addComment", formId) ; + }, + + removeComment : function(iComment) { + checkForOpenedDialog(iComment, function() { + if (gLayout.isInFrame()) { + parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"), gettext("Warning"), function() { this.animateToTop() ;}, this, null, function() { + var comment = gDb.getComment(iComment.commentId) ; + this._q.add( + {fn:CY.bind(this.setPreventClickOn, this)}, + {autoContinue:false, fn:CY.bind(doExchange, null, "removeComment", {'comment_key':comment.key}, null, this.removeCommentRet, this, {'iComment':iComment}, gettext("could not remove comment"))} + ).run(); + }, this, null) ; + + } +// else { +// alert("TODO : can't yet delete comments when not embed in text_view_frame because can't 'dialog' confirmation") ; +// } + + }, this, null) ; + }, + + resume : function(commentDbIds, mouseXY) { + this._q.run() ; + }, + + resetAutoContinue : function(callbackId) { + this._q.getCallback(callbackId).autoContinue = true; + }, + + hideICommentForm : function(funObj) { +// this._q.add({fn:function() {persistICommentFormValues();}}) ; + this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationHide'].run, gICommentForm['animationHide'])}) ; +// this._q.add({fn:function() {cleanICommentForm();}}) ; + if (funObj) + this._q.add(funObj) ; + }, + + /* ANIMATION DRIVEN INTERFACE CHANGES */ + + showCommentForm : function(iComment) { + checkForOpenedDialog(null, function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); + this._q.add({fn:function() { + if (iComment == null) { + var selection = getSelectionInfo() ; + updateICommentFormSelection(selection) ; + } + showICommentForm(iComment); + }}) ; + this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationShow'].run, gICommentForm['animationShow'])}, + {fn:CY.bind(this.setPreventClickOff, this)} + ).run(); + }, this, null) ; + }, + + showEditForm : function(iComment) { + checkForOpenedDialog(null, function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() { - showEditForm(iComment) ; - }}); - this._animateToTop() ; - - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); - this._q.run() ; - }, this, null) ; - }, - - showReplyForm : function(iComment) { - checkForOpenedDialog(null, function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); + this._q.add({fn:function() { + showEditForm(iComment) ; + }}); + this._animateToTop() ; + + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); + this._q.run() ; + }, this, null) ; + }, + + showReplyForm : function(iComment) { + checkForOpenedDialog(null, function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() { - instanciateNewReplyForm(iComment) ; - }}); - this._animateToTop() ; - - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); - this._q.run() ; - }, this, null) ; - }, - - cancelICommentForm : function() { + this._q.add({fn:function() { + instanciateNewReplyForm(iComment) ; + }}); + this._animateToTop() ; + + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); + this._q.run() ; + }, this, null) ; + }, + + cancelICommentForm : function() { this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); -// this._q.add({fn:function() {cleanICommentForm();}}) ; - this.hideICommentForm() ; - +// this._q.add({fn:function() {cleanICommentForm();}}) ; + this.hideICommentForm() ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); this._q.run() ; - }, - cancelEdit : function() { + }, + cancelEdit : function() { this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() {cancelEditForm();}}) ; - this._animateToTop() ; - + this._q.add({fn:function() {cancelEditForm();}}) ; + this._animateToTop() ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); this._q.run() ; - }, - cancelReply : function() { + }, + cancelReply : function() { this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() {cancelNewReplyForm();}}) ; - this._animateToTop() ; - + this._q.add({fn:function() {cancelNewReplyForm();}}) ; + this._animateToTop() ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); this._q.run() ; - }, - changeScopeFormClick : function() { + }, + changeScopeFormClick : function() { this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); - this._q.add({fn:function() {changeScopeFormClick();}}) ; - this._animateToTop() ; - + this._q.add({fn:function() {changeScopeFormClick();}}) ; + this._animateToTop() ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); this._q.run() ; - }, - // this is invoked during queue execution - _hideNewReplyForm : function() { - this._q.add({fn:function() { - cleanNewReplyForm() ; - cancelNewReplyForm() ;}}) ; - }, - // this is invoked during queue execution - _hideEditForm : function() { - this._q.add({fn:function() { - cancelEditForm() ;}}) ; - }, - // this is invoked during queue execution - _insertReply : function(comment) { - this._q.add({fn:function() { - var parentComment = gDb.getComment(comment.reply_to_id) ; - var parentThread = gDb.getThreads([parentComment]) ; - var previousComment = parentThread[parentThread.length - 2] ; // - 2 because now that comment has been added comment is parentThread[parentThread.length - 1] + }, + // this is invoked during queue execution + _hideNewReplyForm : function() { + this._q.add({fn:function() { + cleanNewReplyForm() ; + cancelNewReplyForm() ;}}) ; + }, + // this is invoked during queue execution + _hideEditForm : function() { + this._q.add({fn:function() { + cancelEditForm() ;}}) ; + }, + // this is invoked during queue execution + _insertReply : function(comment) { + this._q.add({fn:function() { + var parentComment = gDb.getComment(comment.reply_to_id) ; + var parentThread = gDb.getThreads([parentComment]) ; + var previousComment = parentThread[parentThread.length - 2] ; // - 2 because now that comment has been added comment is parentThread[parentThread.length - 1] - var iComment = gIComments.insertAfter(previousComment, comment) ; - // iComment CAN'T BE NULL ! (TODO check that there is a - // check server side that parent exists when adding a reply - // !) - - var parentPosition = gIComments.getPosition(comment.reply_to_id) ; - iComment.setPosition(parentPosition) ; - - // check if activation is necessary (will always be ?) - var comment_path = gDb.getPath(comment) ; - var topComment = comment_path[comment_path.length - 1] ; - if (gIComments.isTopActive(topComment.id)) - iComment.activate() ; + var iComment = gIComments.insertAfter(previousComment, comment) ; + // iComment CAN'T BE NULL ! (TODO check that there is a + // check server side that parent exists when adding a reply + // !) + + var parentPosition = gIComments.getPosition(comment.reply_to_id) ; + iComment.setPosition(parentPosition) ; + + // check if activation is necessary (will always be ?) + var comment_path = gDb.getPath(comment) ; + var topComment = comment_path[comment_path.length - 1] ; + if (gIComments.isTopActive(topComment.id)) + iComment.activate() ; - iComment.show() ;}}) ; - this._animateToTop() ; - }, - _showSingleComment : function(comment) { - if (comment != null) { - var path = gDb.getPath(comment) ; - var topAncestorComment = path[path.length - 1] ; - var topY = 0 ; - if (comment['start_wrapper'] != -1) - topY = CY.get(".c-id-"+topAncestorComment.id).getY() ; - else - topY = CY.get('document').get('scrollTop') ; - - this._showComments([topAncestorComment.id], topY, false) ; - // optim when browsing comments with no reply - if (topAncestorComment.replies.length > 0) - this._animateTo(topY) ; - } - }, - _showFocusSingleComment : function(topComment, focusComment, reply) { - if (topComment != null) { - var topY = 0 ; - if (topComment['start_wrapper'] != -1) - topY = CY.get(".c-id-"+topComment.id).getY() ; - else - topY = CY.get('document').get('scrollTop') ; - - this._showComments([topComment.id], topY, false) ; - // optim when browsing comments with no reply - if (topComment.replies.length > 0 || reply) - this._animateToAndFocus(topY, focusComment.id, reply) ; - } - }, + iComment.show() ;}}) ; + this._animateToTop() ; + }, + _showSingleComment : function(comment) { + if (comment != null) { + var path = gDb.getPath(comment) ; + var topAncestorComment = path[path.length - 1] ; + var topY = 0 ; + if (comment['start_wrapper'] != -1) + topY = CY.get(".c-id-"+topAncestorComment.id).getY() ; + else + topY = CY.get('document').get('scrollTop') ; + + this._showComments([topAncestorComment.id], topY, false) ; + // optim when browsing comments with no reply + if (topAncestorComment.replies.length > 0) + this._animateTo(topY) ; + } + }, + _showFocusSingleComment : function(topComment, focusComment, reply) { + if (topComment != null) { + var topY = 0 ; + if (topComment['start_wrapper'] != -1) + topY = CY.get(".c-id-"+topComment.id).getY() ; + else + topY = CY.get('document').get('scrollTop') ; + + this._showComments([topComment.id], topY, false) ; + // optim when browsing comments with no reply + if (topComment.replies.length > 0 || reply) + this._animateToAndFocus(topY, focusComment.id, reply) ; + } + }, - showSingleComment : function(comment) { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - this._showSingleComment(comment) ; - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run(); - }, - - showFocusSingleComment : function(topComment, focusComment, reply) { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - this._showFocusSingleComment(topComment, focusComment, reply) ; - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run(); - }, - - browse : function(order, whereto) { - var comment = gIComments.browse(order, whereto) ; - if (comment != null) - this.showSingleComment(comment) ; - }, - - _showComments : function(commentDbIds, topY, atDocumentTop) { - this._q.add( - {fn:function() { - gShowingAllComments = atDocumentTop ; - gIComments.hide() ; - var cs = CY.Array.map(commentDbIds, function(id) { return gDb.getComment(id) ; }) ; - var comments = gDb.getThreads(cs) ; - gIComments.fetch(comments) ; - - if (commentDbIds.length > 0) { - if (atDocumentTop) { - CY.get('document').set('scrollTop', 0) ; - } - else { - gIComments.activate(commentDbIds[0]) ; - var scopeStart = CY.get(".c-id-"+commentDbIds[0]) ; - if (scopeStart && !scopeStart.inViewportRegion()) // scopeStart could be null when comment has no scope - scopeStart.scrollIntoView(true) ; - } - } - - gIComments.setPosition([gConf['iCommentLeftPadding'], topY]) ; - - gIComments.show() ; - }}) ; - }, - - _animateTo : function(topY) { - this._q.add({fn:function() { - gIComments.setAnimationToPositions(topY) ; - }}, - {id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} - ) ; - }, - - _animateToAndFocus : function(topY, focusCommentId, reply) { - this._q.add({fn:function() { - gIComments.setAnimationToPositionsAndFocus(topY, focusCommentId, reply) ; - }}, - {id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} - ) ; - }, - - _animateToTop : function() { - var topPos = gIComments.getTopPosition() ; - if (topPos != null) - this._animateTo(topPos[1]) ; - }, - - animateToTop : function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - this._animateToTop() ; - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run(); - }, - - showAllComments : function() { - checkForOpenedDialog(null, function() { - gShowingAllComments = true ; - var allTopComments = CY.Array.map(gDb.comments, function(c){return c.id;}) ; - this.showComments(allTopComments, [0,0], true) ; - }, this, null) ; - }, + showSingleComment : function(comment) { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + this._showSingleComment(comment) ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run(); + }, + + showFocusSingleComment : function(topComment, focusComment, reply) { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + this._showFocusSingleComment(topComment, focusComment, reply) ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run(); + }, + + browse : function(order, whereto) { + var comment = gIComments.browse(order, whereto) ; + if (comment != null) + this.showSingleComment(comment) ; + }, + + _showComments : function(commentDbIds, topY, atDocumentTop) { + this._q.add( + {fn:function() { + gShowingAllComments = atDocumentTop ; + gIComments.hide() ; + var cs = CY.Array.map(commentDbIds, function(id) { return gDb.getComment(id) ; }) ; + var comments = gDb.getThreads(cs) ; + gIComments.fetch(comments) ; + + if (commentDbIds.length > 0) { + if (atDocumentTop) { + CY.get('document').set('scrollTop', 0) ; + } + else { + gIComments.activate(commentDbIds[0]) ; + var scopeStart = CY.get(".c-id-"+commentDbIds[0]) ; + if (scopeStart && !scopeStart.inViewportRegion()) // scopeStart could be null when comment has no scope + scopeStart.scrollIntoView(true) ; + } + } + + gIComments.setPosition([gConf['iCommentLeftPadding'], topY]) ; + + gIComments.show() ; + }}) ; + }, + + _animateTo : function(topY) { + this._q.add({fn:function() { + gIComments.setAnimationToPositions(topY) ; + }}, + {id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} + ) ; + }, + + _animateToAndFocus : function(topY, focusCommentId, reply) { + this._q.add({fn:function() { + gIComments.setAnimationToPositionsAndFocus(topY, focusCommentId, reply) ; + }}, + {id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} + ) ; + }, + + _animateToTop : function() { + var topPos = gIComments.getTopPosition() ; + if (topPos != null) + this._animateTo(topPos[1]) ; + }, + + animateToTop : function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + this._animateToTop() ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run(); + }, + + showAllComments : function() { + checkForOpenedDialog(null, function() { + gShowingAllComments = true ; + var allTopComments = CY.Array.map(gDb.comments, function(c){return c.id;}) ; + this.showComments(allTopComments, [0,0], true) ; + }, this, null) ; + }, - showScopeRemovedComments : function() { - checkForOpenedDialog(null, function() { - gShowingAllComments = true ; - var scopeRemovedComments = CY.Array.filter(gDb.comments, function(comment) { return (comment.start_wrapper == -1) ; }) ; - var scopeRemovedCommentIds = CY.Array.map(scopeRemovedComments, function(c){return c.id;}) ; - this.showComments(scopeRemovedCommentIds, [0,0], true) ; - - }, this, null) ; - }, + showScopeRemovedComments : function() { + checkForOpenedDialog(null, function() { + gShowingAllComments = true ; + var scopeRemovedComments = CY.Array.filter(gDb.comments, function(comment) { return (comment.start_wrapper == -1) ; }) ; + var scopeRemovedCommentIds = CY.Array.map(scopeRemovedComments, function(c){return c.id;}) ; + this.showComments(scopeRemovedCommentIds, [0,0], true) ; + + }, this, null) ; + }, - showComments : function(commentDbIds, mouseXY, atDocumentTop) { - checkForOpenedDialog(null, function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - this._showComments(commentDbIds, mouseXY[1], atDocumentTop) ; - this._animateTo(mouseXY[1]) ; - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run(); - }, this, null) ; - }, + showComments : function(commentDbIds, mouseXY, atDocumentTop) { + checkForOpenedDialog(null, function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + this._showComments(commentDbIds, mouseXY[1], atDocumentTop) ; + this._animateTo(mouseXY[1]) ; + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run(); + }, this, null) ; + }, - openComment : function(iComment) { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + openComment : function(iComment) { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - var y = gIComments.getTopPosition()[1] ; - this._q.add({fn:function() { - gIComments.open(iComment.commentId) ; - gIComments.refresh(iComment.commentId) ; - }}) ; - this._animateTo(y) ; - - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run(); - }, - - closeComment : function(iComment) { - checkForOpenedDialog(iComment, function() { - this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; - - var y = gIComments.getTopPosition()[1] ; - this._q.add({fn:function() { - var comment = gDb.getComment(iComment.commentId) ; - gIComments.close(iComment.commentId) ; - if (comment.reply_to_id != null) - gIComments.refresh(comment.reply_to_id) ; - }}) ; - this._animateTo(y) ; - - this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; - this._q.run() ; - }, this, null) ; - }, - - activate : function(iComment) { - gIComments.activate(iComment.commentId) ; - } + var y = gIComments.getTopPosition()[1] ; + this._q.add({fn:function() { + gIComments.open(iComment.commentId) ; + gIComments.refresh(iComment.commentId) ; + }}) ; + this._animateTo(y) ; + + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run(); + }, + + closeComment : function(iComment) { + checkForOpenedDialog(iComment, function() { + this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; + + var y = gIComments.getTopPosition()[1] ; + this._q.add({fn:function() { + var comment = gDb.getComment(iComment.commentId) ; + gIComments.close(iComment.commentId) ; + if (comment.reply_to_id != null) + gIComments.refresh(comment.reply_to_id) ; + }}) ; + this._animateTo(y) ; + + this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; + this._q.run() ; + }, this, null) ; + }, + + activate : function(iComment) { + gIComments.activate(iComment.commentId) ; + } } - + readyForAction = function () { - return !gSync._iPreventClick ; + return !gSync._iPreventClick ; }; diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_util.js --- a/src/cm/media/js/client/c_util.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_util.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,32 +1,32 @@ _changeIds = function(elt, suffix) { - if (elt.id) - elt.id = elt.id + suffix ; - var c = elt.firstChild ; - while (c != null) { - _changeIds(c, suffix) ; - c = c.nextSibling ; - } + if (elt.id) + elt.id = elt.id + suffix ; + var c = elt.firstChild ; + while (c != null) { + _changeIds(c, suffix) ; + c = c.nextSibling ; + } } ; suffix = 0 ; domDuplicate = function(elt) { - var newElt = elt.cloneNode(true) ; - suffix++ ; - _changeIds(newElt, '-'+suffix) ; - return newElt ; + var newElt = elt.cloneNode(true) ; + suffix++ ; + _changeIds(newElt, '-'+suffix) ; + return newElt ; } ; getDuplicated = function(elt) { - return document.getElementById(elt.id + '-' + suffix) ; + return document.getElementById(elt.id + '-' + suffix) ; } ; logSel = function(selection) { - log('text :' + selection['text'] + ', start id : ' + selection['start']['elt'].id + ' , start offset : ' + selection['start']['offset'] + ' , end id : ' + selection['end']['elt'].id + 'end offset : ' + selection['end']['offset']) ; + log('text :' + selection['text'] + ', start id : ' + selection['start']['elt'].id + ' , start offset : ' + selection['start']['offset'] + ' , end id : ' + selection['end']['elt'].id + 'end offset : ' + selection['end']['offset']) ; } ; log = function (msg) { - var log = document.getElementById("log") ; - log.innerHTML = log.innerHTML + "
  • " + msg + "
  • " ; + var log = document.getElementById("log") ; + log.innerHTML = log.innerHTML + "
  • " + msg + "
  • " ; } ; // from ext @@ -92,83 +92,83 @@ areSortedArraysEqual = function (a1, a2) { - if (a1.length != a2.length) - return false ; - for (var i = 0, ilen = a1.length ; i < ilen ; i++) { - if (a1[i] != a2[i]) - return false ; - } - return true + if (a1.length != a2.length) + return false ; + for (var i = 0, ilen = a1.length ; i < ilen ; i++) { + if (a1[i] != a2[i]) + return false ; + } + return true } ; // in place ordering! quicksort = function (vec) { - _quicksort(vec, 0, vec.length-1) ; + _quicksort(vec, 0, vec.length-1) ; }; // cf. http://www.4guysfromrolla.com/webtech/012799-1.shtml _quicksort = function (vec, loBound, hiBound) /************************************************************** - This function adapted from the algorithm given in: - Data Abstractions & Structures Using C++, by - Mark Headington and David Riley, pg. 586. + This function adapted from the algorithm given in: + Data Abstractions & Structures Using C++, by + Mark Headington and David Riley, pg. 586. - quicksort is the fastest array sorting routine for - unordered arrays. Its big O is n log n. + quicksort is the fastest array sorting routine for + unordered arrays. Its big O is n log n. **************************************************************/ { - var pivot, loSwap, hiSwap, temp; + var pivot, loSwap, hiSwap, temp; - // Two items to sort - if (hiBound - loBound == 1) - { - if (vec[loBound] > vec[hiBound]) - { - temp = vec[loBound]; - vec[loBound] = vec[hiBound]; - vec[hiBound] = temp; - } - return; - } + // Two items to sort + if (hiBound - loBound == 1) + { + if (vec[loBound] > vec[hiBound]) + { + temp = vec[loBound]; + vec[loBound] = vec[hiBound]; + vec[hiBound] = temp; + } + return; + } - // Three or more items to sort - pivot = vec[parseInt((loBound + hiBound) / 2)]; - vec[parseInt((loBound + hiBound) / 2)] = vec[loBound]; - vec[loBound] = pivot; - loSwap = loBound + 1; - hiSwap = hiBound; + // Three or more items to sort + pivot = vec[parseInt((loBound + hiBound) / 2)]; + vec[parseInt((loBound + hiBound) / 2)] = vec[loBound]; + vec[loBound] = pivot; + loSwap = loBound + 1; + hiSwap = hiBound; - do { - // Find the right loSwap - while (loSwap <= hiSwap && vec[loSwap] <= pivot) - loSwap++; + do { + // Find the right loSwap + while (loSwap <= hiSwap && vec[loSwap] <= pivot) + loSwap++; - // Find the right hiSwap - while (vec[hiSwap] > pivot) - hiSwap--; + // Find the right hiSwap + while (vec[hiSwap] > pivot) + hiSwap--; - // Swap values if loSwap is less than hiSwap - if (loSwap < hiSwap) - { - temp = vec[loSwap]; - vec[loSwap] = vec[hiSwap]; - vec[hiSwap] = temp; - } - } while (loSwap < hiSwap); + // Swap values if loSwap is less than hiSwap + if (loSwap < hiSwap) + { + temp = vec[loSwap]; + vec[loSwap] = vec[hiSwap]; + vec[hiSwap] = temp; + } + } while (loSwap < hiSwap); - vec[loBound] = vec[hiSwap]; - vec[hiSwap] = pivot; + vec[loBound] = vec[hiSwap]; + vec[hiSwap] = pivot; - // Recursively call function... the beauty of quicksort + // Recursively call function... the beauty of quicksort - // 2 or more items in first section - if (loBound < hiSwap - 1) - _quicksort(vec, loBound, hiSwap - 1); + // 2 or more items in first section + if (loBound < hiSwap - 1) + _quicksort(vec, loBound, hiSwap - 1); - // 2 or more items in second section - if (hiSwap + 1 < hiBound) - _quicksort(vec, hiSwap + 1, hiBound); + // 2 or more items in second section + if (hiSwap + 1 < hiBound) + _quicksort(vec, hiSwap + 1, hiBound); } ; diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/f_message.js --- a/src/cm/media/js/client/f_message.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/f_message.js Tue Nov 30 09:53:35 2010 +0100 @@ -10,41 +10,41 @@ // this == dom element onFadeEnd = function () { - $(this).remove() ; + $(this).remove() ; } ; gLoadingMsg = null ; enqueueLoadingMsg = function() { - gLoadingMsg = _enqueueMsg (gettext("loading..."), "", null) ; + gLoadingMsg = _enqueueMsg (gettext("loading..."), "", null) ; } removeLoadingMsg = function() { - if (gLoadingMsg != null) { - gLoadingMsg.remove() ; - gLoadingMsg = null ; - } + if (gLoadingMsg != null) { + gLoadingMsg.remove() ; + gLoadingMsg = null ; + } } _enqueueMsg = function(msg, cls, remainVisibleTime) { - var m = $('' + msg + '').appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(cls) ; - if (remainVisibleTime) - m.animate({'opacity':.95}, remainVisibleTime).fadeOut(2000, onFadeEnd) ; - return m ; - + var m = $('' + msg + '').appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(cls) ; + if (remainVisibleTime) + m.animate({'opacity':.95}, remainVisibleTime).fadeOut(2000, onFadeEnd) ; + return m ; + } enqueueMsg = function(msg) { -// while ($("#c-msg-wrapper .f-msg-cls").children().size() > 1) { -// $("#c-msg-wrapper .f-msg-cls:first").stop(false, true) ; -// } -// - var cls = "f-msg" ; - var remainVisibleTime = 8000 ; - _enqueueMsg(msg, cls, remainVisibleTime) ; +// while ($("#c-msg-wrapper .f-msg-cls").children().size() > 1) { +// $("#c-msg-wrapper .f-msg-cls:first").stop(false, true) ; +// } +// + var cls = "f-msg" ; + var remainVisibleTime = 8000 ; + _enqueueMsg(msg, cls, remainVisibleTime) ; } enqueueErrorMsg = function(msg) { - var cls = "f-msg-e" ; - var remainVisibleTime = 4000 ; - _enqueueMsg(msg, cls, remainVisibleTime) ; + var cls = "f-msg-e" ; + var remainVisibleTime = 4000 ; + _enqueueMsg(msg, cls, remainVisibleTime) ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/f_printDialog.js --- a/src/cm/media/js/client/f_printDialog.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/f_printDialog.js Tue Nov 30 09:53:35 2010 +0100 @@ -11,145 +11,145 @@ gActions = {'print':{'dialogTitle':gettext('Print text'), 'chooseFormatLabel':gettext('How do you want to print?'), 'defaultMethod':'pdf', 'defaultWithColors':"no", 'defaultWhichComments':'all'}, - 'export':{'dialogTitle':gettext('Export text'), 'chooseFormatLabel':gettext('Choose file format'), 'defaultMethod':'pdf', 'defaultWithColors':"no", 'defaultWhichComments':'all'}} ; + 'export':{'dialogTitle':gettext('Export text'), 'chooseFormatLabel':gettext('Choose file format'), 'defaultMethod':'pdf', 'defaultWithColors':"no", 'defaultWhichComments':'all'}} ; gCurrentAction = null ; - + _populateMethod = function(withColors) { - var val = $("#p_method").val(); - - $("#p_method").html(""); - - for (var i = 0, ilen = gFormats.length ; i < ilen ; i++) { - var actions = gFormats[i]['actions'] ; - for (var j = 0, jlen = gFormats.length ; j < jlen ; j++) { - if (actions[j] == gCurrentAction) - $("").appendTo("#p_method"); - } - } - if (val) - $("#p_method").val(val); - else - $("#p_method").val(gActions[gCurrentAction]['defaultMethod']); - + var val = $("#p_method").val(); + + $("#p_method").html(""); + + for (var i = 0, ilen = gFormats.length ; i < ilen ; i++) { + var actions = gFormats[i]['actions'] ; + for (var j = 0, jlen = gFormats.length ; j < jlen ; j++) { + if (actions[j] == gCurrentAction) + $("").appendTo("#p_method"); + } + } + if (val) + $("#p_method").val(val); + else + $("#p_method").val(gActions[gCurrentAction]['defaultMethod']); + } ; _populateMarkersColorsChoice = function(withColors) { - var val = $("#p_color").val(); - - $("#p_color").html(""); - - $("").appendTo("#p_color"); - $("").appendTo("#p_color"); + var val = $("#p_color").val(); + + $("#p_color").html(""); + + $("").appendTo("#p_color"); + $("").appendTo("#p_color"); - if (val) - $("#p_color").val(val); - else - $("#p_color").val(gActions[gCurrentAction]['defaultWithColors']); + if (val) + $("#p_color").val(val); + else + $("#p_color").val(gActions[gCurrentAction]['defaultWithColors']); } ; _populateWhichComments = function() { - var val = $("#p_comments").val(); + var val = $("#p_comments").val(); - $("#p_comments").html(""); - var all = interpolate(gettext("all (%(nb_comments)s)"), {'nb_comments':frames['text_view_comments'].gDb.getCommentsNb(true)}, true) ; - var currents = interpolate(gettext("current filtered ones (%(nb_comments)s)"), {'nb_comments':frames['text_view_comments'].gDb.getCommentsNb(false)}, true) ; - $("").appendTo($("#p_comments")) ; - $("").appendTo($("#p_comments")) ; - $("").appendTo($("#p_comments")) ; - - if (val) - $("#p_comments").val(val); - else - $("#p_comments").val(gActions[gCurrentAction]['defaultWhichComments']); + $("#p_comments").html(""); + var all = interpolate(gettext("all (%(nb_comments)s)"), {'nb_comments':frames['text_view_comments'].gDb.getCommentsNb(true)}, true) ; + var currents = interpolate(gettext("current filtered ones (%(nb_comments)s)"), {'nb_comments':frames['text_view_comments'].gDb.getCommentsNb(false)}, true) ; + $("").appendTo($("#p_comments")) ; + $("").appendTo($("#p_comments")) ; + $("").appendTo($("#p_comments")) ; + + if (val) + $("#p_comments").val(val); + else + $("#p_comments").val(gActions[gCurrentAction]['defaultWhichComments']); } ; _manageMarkersColorsChoice = function() { - var method = $("#p_method").val(); - var which = $("#p_comments").val(); - - var disableMarkersColorsChoice ; - if (gCurrentAction == 'print') - disableMarkersColorsChoice = ((which == 'none') || (method == 'markdown') || (method == 'html')) ; - if (gCurrentAction == 'export') - disableMarkersColorsChoice = ((which == 'none') || (method == 'markdown')) ; - - if (disableMarkersColorsChoice) - $("#p_color").val('no'); + var method = $("#p_method").val(); + var which = $("#p_comments").val(); + + var disableMarkersColorsChoice ; + if (gCurrentAction == 'print') + disableMarkersColorsChoice = ((which == 'none') || (method == 'markdown') || (method == 'html')) ; + if (gCurrentAction == 'export') + disableMarkersColorsChoice = ((which == 'none') || (method == 'markdown')) ; + + if (disableMarkersColorsChoice) + $("#p_color").val('no'); - $("#p_color").attr("disabled", disableMarkersColorsChoice); - + $("#p_color").attr("disabled", disableMarkersColorsChoice); + } ; _initPrintDialog = function() { - $('#p_comments').add($('#p_method')).change(function() { - _manageMarkersColorsChoice() ; - _prepareOpenInNewWindow() ; - }) ; + $('#p_comments').add($('#p_method')).change(function() { + _manageMarkersColorsChoice() ; + _prepareOpenInNewWindow() ; + }) ; - var buttons = {} ; - buttons[gettext('Go !')] = function() { - var whichComments = $("#p_comments").val() ; - var withColor = $("#p_color").val() ; - var format = $("#p_method").val() ; - var download = (gCurrentAction == "export") ? "1" : (format == "html") ? "0" : "1" ; - var targetUrl = $("#print_export_form").attr('target_action').replace(/FoRmAt/,format).replace(/DoWnLoAd/, download).replace(/WhIcHCoMmEnT/, whichComments).replace(/WiThCoLoR/, withColor) ; - $("#print_export_form").attr('action', targetUrl) ; - - document['print_export_form'].submit(); - $(this).dialog('close'); - } ; - buttons[gettext('Cancel')] = function() { - $(this).dialog('close'); - } ; + var buttons = {} ; + buttons[gettext('Go !')] = function() { + var whichComments = $("#p_comments").val() ; + var withColor = $("#p_color").val() ; + var format = $("#p_method").val() ; + var download = (gCurrentAction == "export") ? "1" : (format == "html") ? "0" : "1" ; + var targetUrl = $("#print_export_form").attr('target_action').replace(/FoRmAt/,format).replace(/DoWnLoAd/, download).replace(/WhIcHCoMmEnT/, whichComments).replace(/WiThCoLoR/, withColor) ; + $("#print_export_form").attr('action', targetUrl) ; + + document['print_export_form'].submit(); + $(this).dialog('close'); + } ; + buttons[gettext('Cancel')] = function() { + $(this).dialog('close'); + } ; - - $("#dialog_print_export").dialog({ - bgiframe: true, - autoOpen: false, - width: 450, -/* height: 300, - autoResize: false,*/ - modal: true, - buttons: buttons, - close: function() { - ; // empty - } - }); + + $("#dialog_print_export").dialog({ + bgiframe: true, + autoOpen: false, + width: 450, +/* height: 300, + autoResize: false,*/ + modal: true, + buttons: buttons, + close: function() { + ; // empty + } + }); } openPrintDialog = function() { - _openPrintExportDialog('print') ; + _openPrintExportDialog('print') ; } openExportDialog = function() { - _openPrintExportDialog('export') ; + _openPrintExportDialog('export') ; } _prepareOpenInNewWindow = function() { - var method = $("#p_method").val(); - if ((method == "html") && (gCurrentAction == 'print')) - $("#print_export_form").attr("target", "_blank") ; - else - $("#print_export_form").removeAttr("target") ; + var method = $("#p_method").val(); + if ((method == "html") && (gCurrentAction == 'print')) + $("#print_export_form").attr("target", "_blank") ; + else + $("#print_export_form").removeAttr("target") ; } _openPrintExportDialog = function(action) { - gCurrentAction = action ; - $("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]['dialogTitle']) ; - $("#how").html(gActions[gCurrentAction]['chooseFormatLabel']) ; - $("#print_export_action").val(action) ; // TODO check this still usefull - - - _populateWhichComments() ; - _populateMarkersColorsChoice() ; - _populateMethod() ; - - _manageMarkersColorsChoice() ; - _prepareOpenInNewWindow() ; + gCurrentAction = action ; + $("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]['dialogTitle']) ; + $("#how").html(gActions[gCurrentAction]['chooseFormatLabel']) ; + $("#print_export_action").val(action) ; // TODO check this still usefull + + + _populateWhichComments() ; + _populateMarkersColorsChoice() ; + _populateMethod() ; + + _manageMarkersColorsChoice() ; + _prepareOpenInNewWindow() ; - $('#dialog_print_export').dialog('open'); + $('#dialog_print_export').dialog('open'); } -/* - tips.text(t).effect("highlight",{},1500); -*/ \ No newline at end of file +/* + tips.text(t).effect("highlight",{},1500); +*/ diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/c_text_view_comments.js --- a/src/cm/media/js/site/c_text_view_comments.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/c_text_view_comments.js Tue Nov 30 09:53:35 2010 +0100 @@ -7,7 +7,7 @@ gGETValues = null; gConf = {'iCommentLeftPadding':4, - 'iCommentThreadPadding':12, + 'iCommentThreadPadding':12, 'defaultCommentFormat':'markdown', 'sliderFixedMin':.9, 'sliderFixedMax':.1, @@ -20,277 +20,277 @@ gTextStyles = {'text-modern-style':gettext('modern'), 'text-classic-style':gettext('classic'), 'text-code-style':gettext('code')}; YUI( { - base :sv_media_url + "/js/lib/yui/" + c_yui_base + "/build/", - // filter: '{% if CLIENT_DEBUG %}debug{% else %}raw{% endif %}', - // filter :'raw', - timeout :10000 + base :sv_media_url + "/js/lib/yui/" + c_yui_base + "/build/", + // filter: '{% if CLIENT_DEBUG %}debug{% else %}raw{% endif %}', + // filter :'raw', + timeout :10000 }).use( - "text-modern-style", - "cookie", - "json", - "overlay", - "io-form", - "async-queue", - "event-mouseenter", - "anim", - "collection", - function(Y) { - CY = Y; - + "text-modern-style", + "cookie", + "json", + "overlay", + "io-form", + "async-queue", + "event-mouseenter", + "anim", + "collection", + function(Y) { + CY = Y; + gPrefs = new Preferences() ; gPrefs.init() ; gLayout = new Layout() ; gLayout.init() ; - if (sv_withComments) { - gDb = new Db() ; - gDb.init() ; - - gIComments = new IComments() ; - gIComments.init() ; - } + if (sv_withComments) { + gDb = new Db() ; + gDb.init() ; + + gIComments = new IComments() ; + gIComments.init() ; + } gSync = new Sync() ; gSync.init() ; - CY.on("domready", onDomReady, this); + CY.on("domready", onDomReady, this); - }); + }); _reinit = function(filterRes) { - gIComments.hide(); - gDb.initComments(filterRes['commentIds']); + gIComments.hide(); + gDb.initComments(filterRes['commentIds']); - unpaintAllComments(); - renderCommentScopes(); - - updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']); + unpaintAllComments(); + renderCommentScopes(); + + updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']); }; reinit = function(filterGETValues) { - var filterRes = gDb.computeFilterResults(filterGETValues); - _reinit(filterRes); + var filterRes = gDb.computeFilterResults(filterGETValues); + _reinit(filterRes); }; hideAll = function() { - _reinit({'commentIds':[],'nbDiscussions':0, 'nbComments':0, 'nbReplies':0}); + _reinit({'commentIds':[],'nbDiscussions':0, 'nbComments':0, 'nbReplies':0}); }; updateFilterResultsCount = function(nbDiscussions, nbComments, nbReplies) { - var r = gDb.getCommentsAndRepliesCounts(true); - var nbAllComments = r[0], nbAllReplies = r[1]; - var detailedResults = (nbComments != 0 || nbReplies != 0) && (nbAllComments != nbComments || nbAllReplies != nbReplies) ; - if (gLayout.isInFrame()) { - parent.f_updateFilterCountDetailed(detailedResults) ; - parent.f_updateFilterCountResult(nbDiscussions, nbComments, nbReplies, nbAllComments, nbAllReplies); - } + var r = gDb.getCommentsAndRepliesCounts(true); + var nbAllComments = r[0], nbAllReplies = r[1]; + var detailedResults = (nbComments != 0 || nbReplies != 0) && (nbAllComments != nbComments || nbAllReplies != nbReplies) ; + if (gLayout.isInFrame()) { + parent.f_updateFilterCountDetailed(detailedResults) ; + parent.f_updateFilterCountResult(nbDiscussions, nbComments, nbReplies, nbAllComments, nbAllReplies); + } }; updateResetFilterResultsCount = function() { - var counts = gDb.getCommentsAndRepliesCounts(false) - var nbComments = counts[0], nbReplies = counts[1]; + var counts = gDb.getCommentsAndRepliesCounts(false) + var nbComments = counts[0], nbReplies = counts[1]; - var nbDiscussions = nbComments; - updateFilterResultsCount(nbDiscussions, nbComments, nbReplies); + var nbDiscussions = nbComments; + updateFilterResultsCount(nbDiscussions, nbComments, nbReplies); }; // TODO MOVE renderCommentScopes = function() { - for (var i = 0 ; i < gDb.comments.length ; i++) { - var comment = gDb.comments[i] ; - paintCommentScope(comment) ; - } + for (var i = 0 ; i < gDb.comments.length ; i++) { + var comment = gDb.comments[i] ; + paintCommentScope(comment) ; + } } ; onTextMouseUp = function(e) { - if (readyForAction()) { - var selection = getSelectionInfo() ; - if (selection != null) { - updateICommentFormSelection(selection) ; - if (gEditICommentHost != null) { - var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ; - if (modifyScope) { - gEditICommentHost.scrollIntoView() ; - } - } - } - else { - var node = e.target ; - if (node.hasClass('c-c')) { - var elt = CY.Node.getDOMNode(node) ; - var commentIds = getCommentIdsFromClasses(elt) ; - if (commentIds.length > 0) { - checkForOpenedDialog(null, function() { // will only check for reply - gSync.showComments(commentIds, [e.pageX, e.pageY], false) ; - }) ; - } - } - } -//// FIRST UPDATE SELECTION IF ANY AND SCROLL TO EDITION IF ANY -// if (isICommentFormVisible() || gEditICommentHost != null) { -// CY.log(selection) ; -// updateICommentFormSelection(selection) ; -// -// if (gEditICommentHost != null) { -// var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ; -// if (modifyScope) { -// gEditICommentHost.scrollIntoView() ; -// didSomething = true ; -// } -// } -// if (isICommentFormVisible()) -// didSomething = true ; -// } -// else { -// checkForOpenedDialog(null, function() { // will only check for reply -// var node = e.target ; -// if (node.hasClass('c-c')) { -// var elt = CY.Node.getDOMNode(node) ; -// var commentIds = getCommentIdsFromClasses(elt) ; -// if (commentIds.length > 0) { -// //hideOverlay(gICommentForm) ; -// // gIComments.hide() ;20080814 moved it to gSync._showComments -// gSync.showComments(commentIds, [e.pageX, e.pageY]) ; -// } -// } -// }) ; -// } - } + if (readyForAction()) { + var selection = getSelectionInfo() ; + if (selection != null) { + updateICommentFormSelection(selection) ; + if (gEditICommentHost != null) { + var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ; + if (modifyScope) { + gEditICommentHost.scrollIntoView() ; + } + } + } + else { + var node = e.target ; + if (node.hasClass('c-c')) { + var elt = CY.Node.getDOMNode(node) ; + var commentIds = getCommentIdsFromClasses(elt) ; + if (commentIds.length > 0) { + checkForOpenedDialog(null, function() { // will only check for reply + gSync.showComments(commentIds, [e.pageX, e.pageY], false) ; + }) ; + } + } + } +//// FIRST UPDATE SELECTION IF ANY AND SCROLL TO EDITION IF ANY +// if (isICommentFormVisible() || gEditICommentHost != null) { +// CY.log(selection) ; +// updateICommentFormSelection(selection) ; +// +// if (gEditICommentHost != null) { +// var modifyScope = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked') ; +// if (modifyScope) { +// gEditICommentHost.scrollIntoView() ; +// didSomething = true ; +// } +// } +// if (isICommentFormVisible()) +// didSomething = true ; +// } +// else { +// checkForOpenedDialog(null, function() { // will only check for reply +// var node = e.target ; +// if (node.hasClass('c-c')) { +// var elt = CY.Node.getDOMNode(node) ; +// var commentIds = getCommentIdsFromClasses(elt) ; +// if (commentIds.length > 0) { +// //hideOverlay(gICommentForm) ; +// // gIComments.hide() ;20080814 moved it to gSync._showComments +// gSync.showComments(commentIds, [e.pageX, e.pageY]) ; +// } +// } +// }) ; +// } + } } ; gLastScrollTime = null ; checkForAlignement = function () { - var now = (new Date()).getTime() ; - if ((gLastScrollTime != null) && (now - gLastScrollTime) > 200) { - positionICommentForm() ; - gLastScrollTime = null ; - } + var now = (new Date()).getTime() ; + if ((gLastScrollTime != null) && (now - gLastScrollTime) > 200) { + positionICommentForm() ; + gLastScrollTime = null ; + } }; onFrameScroll = function () { - gLastScrollTime = (new Date()).getTime() ; + gLastScrollTime = (new Date()).getTime() ; }; browse = function(order, whereto) { - gSync.browse(order, whereto) ; + gSync.browse(order, whereto) ; }; initialConnect = function() { - CY.on("mouseup", onTextMouseUp, "#textcontainer"); - gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ; - CY.on('scroll', onFrameScroll, window, this, true); - CY.on('resize', onFrameScroll, window, this, true); + CY.on("mouseup", onTextMouseUp, "#textcontainer"); + gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ; + CY.on('scroll', onFrameScroll, window, this, true); + CY.on('resize', onFrameScroll, window, this, true); }; preventLinksInText = function() { - var interceptLink = function(e) { - var a = e.target; - var href = null; - while (a != null && href == null) { - a = a.get('parentNode'); - href = a.get("href"); - } - - if (a != null && href != null) { - //alert(window.location) ; - var clean_window_location = window.location.href ; - - var ind = clean_window_location.indexOf('#') ; - if (ind != -1) - clean_window_location = clean_window_location.substring(0, ind) ; - - if (href.indexOf(clean_window_location) == -1 ) { - window.open(a.get("href")); - e.preventDefault(); ; - } - } - } ; + var interceptLink = function(e) { + var a = e.target; + var href = null; + while (a != null && href == null) { + a = a.get('parentNode'); + href = a.get("href"); + } + + if (a != null && href != null) { + //alert(window.location) ; + var clean_window_location = window.location.href ; + + var ind = clean_window_location.indexOf('#') ; + if (ind != -1) + clean_window_location = clean_window_location.substring(0, ind) ; + + if (href.indexOf(clean_window_location) == -1 ) { + window.open(a.get("href")); + e.preventDefault(); ; + } + } + } ; - CY.all("#textcontainer a").on("click", interceptLink); + CY.all("#textcontainer a").on("click", interceptLink); }; onDomReady = function(arg1) { - preventLinksInText(); - var q1 = new CY.AsyncQueue(); // - // doesn't behave like the doc says : - // no timeout -> seems in blocking mode - q1.add( { - fn : function() { + preventLinksInText(); + var q1 = new CY.AsyncQueue(); // + // doesn't behave like the doc says : + // no timeout -> seems in blocking mode + q1.add( { + fn : function() { - if (gLayout.isInComentSite()) { - parent.toInitialSize(); - } - if (sv_withComments) { - instanciateICommentForm(); - } - }, - timeout :5 - }, { - fn : function() { + if (gLayout.isInComentSite()) { + parent.toInitialSize(); + } + if (sv_withComments) { + instanciateICommentForm(); + } + }, + timeout :5 + }, { + fn : function() { - gGETValues = CY.JSON.parse(sv_get_params); - - CY.get('#maincontainer').setStyle('display', 'block'); - CY.get('#textcontainer').setStyle('display', 'block'); - - var val = (sv_withComments) ? gPrefs.get('layout','comments_col_width') : 0 ; - var colWidth = sliderValToPx(val) ; - gLayout.setLeftColumnWidth(colWidth) ; - - if (gLayout.isInFrame()) { - parent.f_initFrame(); - parent.f_layoutFrames(); + gGETValues = CY.JSON.parse(sv_get_params); + + CY.get('#maincontainer').setStyle('display', 'block'); + CY.get('#textcontainer').setStyle('display', 'block'); + + var val = (sv_withComments) ? gPrefs.get('layout','comments_col_width') : 0 ; + var colWidth = sliderValToPx(val) ; + gLayout.setLeftColumnWidth(colWidth) ; + + if (gLayout.isInFrame()) { + parent.f_initFrame(); + parent.f_layoutFrames(); - if (sv_withComments) { - parent.f_fillTopToolbar() ; - if (hasPerm("can_create_comment"))  - parent.$("#add_comment_btn").removeClass('initially_hidden'); - //parent.enqueueLoadingMsg(); // no more loading message ? TODO - - parent.f_fillFilterTab() ; - parent.f_fillPreferencesTab() ; - -// parent.f_fillBrowseSection() ; - - var firstTimeFilterData = CY.JSON.parse(sv_filter_data); - parent.f_updateFilterData(firstTimeFilterData); - - parent.f_setFilterValue(gGETValues) ; - } - parent.f_fillTextPreferencesTab() ; - } - - if (gLayout.isInComentSite()) - parent.$("#c_fullscreen_btn").show(); - else { - parent.$("#c_fullscreen_btn").hide(); - } + if (sv_withComments) { + parent.f_fillTopToolbar() ; + if (hasPerm("can_create_comment"))  + parent.$("#add_comment_btn").removeClass('initially_hidden'); + //parent.enqueueLoadingMsg(); // no more loading message ? TODO + + parent.f_fillFilterTab() ; + parent.f_fillPreferencesTab() ; + +// parent.f_fillBrowseSection() ; + + var firstTimeFilterData = CY.JSON.parse(sv_filter_data); + parent.f_updateFilterData(firstTimeFilterData); + + parent.f_setFilterValue(gGETValues) ; + } + parent.f_fillTextPreferencesTab() ; + } + + if (gLayout.isInComentSite()) + parent.$("#c_fullscreen_btn").show(); + else { + parent.$("#c_fullscreen_btn").hide(); + } - }, - timeout :5 - }, { - fn : function() { - if (sv_withComments) { - - reinit(gGETValues); - initialConnect(); - } - }, - timeout :5 - }, { - fn : function() { - if (gLayout.isInFrame()) { - parent.f_interfaceUnfreeze() ; - parent.f_removeLoadingMsg(); - } - // if there is a comment id in the url display it - if ("comment_id_key" in gGETValues) { - var id_key = gGETValues["comment_id_key"] ; - var comment = gDb.getCommentByIdKey(id_key) ; - if (comment != null) { - var path = gDb.getPath(comment) ; - var topParentComment = path[path.length - 1] ; + }, + timeout :5 + }, { + fn : function() { + if (sv_withComments) { + + reinit(gGETValues); + initialConnect(); + } + }, + timeout :5 + }, { + fn : function() { + if (gLayout.isInFrame()) { + parent.f_interfaceUnfreeze() ; + parent.f_removeLoadingMsg(); + } + // if there is a comment id in the url display it + if ("comment_id_key" in gGETValues) { + var id_key = gGETValues["comment_id_key"] ; + var comment = gDb.getCommentByIdKey(id_key) ; + if (comment != null) { + var path = gDb.getPath(comment) ; + var topParentComment = path[path.length - 1] ; var focusComment = gDb.getCommentByIdKey(id_key); // if comment_op=reply, show reply form if ("comment_op" in gGETValues && gGETValues["comment_op"] == 'reply') { @@ -299,19 +299,19 @@ else { gSync.showFocusSingleComment(topParentComment, focusComment, false) ; } - } - } + } + } - // if comment_auto_display: show all comments - if ("comments_auto_display" in gGETValues) { - gSync.showAllComments(); - } - -// else { -// gSync.showAllComments() ;// show all -// } - } - }); - q1.run(); + // if comment_auto_display: show all comments + if ("comments_auto_display" in gGETValues) { + gSync.showAllComments(); + } + +// else { +// gSync.showAllComments() ;// show all +// } + } + }); + q1.run(); }; diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/c_text_view_comments_to_frame.js --- a/src/cm/media/js/site/c_text_view_comments_to_frame.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/c_text_view_comments_to_frame.js Tue Nov 30 09:53:35 2010 +0100 @@ -2,52 +2,52 @@ c_persistPreference = function(key1, key2, val) { - gPrefs.persist(key1, key2, val) ; + gPrefs.persist(key1, key2, val) ; } c_readDefaultPreference = function(key1, key2) { - return gConf['defaultPrefs'][key1][key2] ; + return gConf['defaultPrefs'][key1][key2] ; } c_readPreference = function(key1, key2) { - return gPrefs.get(key1,key2) ; + return gPrefs.get(key1,key2) ; } c_resetPreferences = function(entries) { - gPrefs.reset(entries) ; + gPrefs.reset(entries) ; } c_applyTextStyle = function(val) { - CY.use(val) ; + CY.use(val) ; } sliderValToPx = function (val) { - var winWidth = CY.DOM.winWidth() ; - if (gLayout.isInFrame()) - winWidth = parent.$(parent).width() ; - var theta = val / 100 ; - theta = Math.min(theta, gConf['sliderFixedMin']) ; - theta = Math.max(theta, gConf['sliderFixedMax']) ; - var colWidth = theta * winWidth ; - return Math.floor(colWidth) ; + var winWidth = CY.DOM.winWidth() ; + if (gLayout.isInFrame()) + winWidth = parent.$(parent).width() ; + var theta = val / 100 ; + theta = Math.min(theta, gConf['sliderFixedMin']) ; + theta = Math.max(theta, gConf['sliderFixedMax']) ; + var colWidth = theta * winWidth ; + return Math.floor(colWidth) ; } c_setCommentsColWidth = function(val) { - var colWidth = sliderValToPx(val) ; - gLayout.setLeftColumnWidth(colWidth) ; + var colWidth = sliderValToPx(val) ; + gLayout.setLeftColumnWidth(colWidth) ; - var iCommentWidth = gLayout.getTopICommentsWidthFromWidth(colWidth) ; + var iCommentWidth = gLayout.getTopICommentsWidthFromWidth(colWidth) ; - // icomments - gIComments.setWidth(iCommentWidth) ; + // icomments + gIComments.setWidth(iCommentWidth) ; - //forms - gICommentForm['overlay'].get('boundingBox').setStyle('width', iCommentWidth + 'px') ; - changeFormFieldsWidth(gICommentForm['formId'], iCommentWidth) ; - - if (gNewReply) - changeFormFieldsWidth(gNewReply['ids']['formId'], iCommentWidth) ; - if (gEdit) - changeFormFieldsWidth(gEdit['ids']['formId'], iCommentWidth) ; + //forms + gICommentForm['overlay'].get('boundingBox').setStyle('width', iCommentWidth + 'px') ; + changeFormFieldsWidth(gICommentForm['formId'], iCommentWidth) ; + + if (gNewReply) + changeFormFieldsWidth(gNewReply['ids']['formId'], iCommentWidth) ; + if (gEdit) + changeFormFieldsWidth(gEdit['ids']['formId'], iCommentWidth) ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/f_text_view_frame.js --- a/src/cm/media/js/site/f_text_view_frame.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/f_text_view_frame.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,753 +1,753 @@ var gResetOtherFieldsOnFilterFieldChange = true; var myDefaultOuterLayoutSettings = { - center : { - paneSelector :".outer-center" - }, - north : { - size :50,//30, - spacing_open :0, - closable :false, - resizable :false - } + center : { + paneSelector :".outer-center" + }, + north : { + size :50,//30, + spacing_open :0, + closable :false, + resizable :false + } }; var innerNorthPaneDefaults = { - 'innerNorthPaneOpened' :'0', - 'selectedTab' :'0' + 'innerNorthPaneOpened' :'0', + 'selectedTab' :'0' }; onInnerNorthPaneClose = function() { - _setCookie('innerNorthPaneOpened', '0'); - $('#add_comment_btn').css('top', 63) ; - return true; + _setCookie('innerNorthPaneOpened', '0'); + $('#add_comment_btn').css('top', 63) ; + return true; } onInnerNorthPaneOpen = function() { - _setCookie('innerNorthPaneOpened', '1'); - $('#add_comment_btn').css('top', 149) ; - return true; + _setCookie('innerNorthPaneOpened', '1'); + $('#add_comment_btn').css('top', 149) ; + return true; } // DEFAULT LAYOUT SETTINGS var myDefaultInnerLayoutSettings = { - north : { - // size: 66, /* 66 for FF */ - size :88, /* 66 for FF */ - spacing_closed :8, - slidable :false, - resizable :false, /* important */ - togglerLength_closed :"100%", - togglerLength_open :"100%", - togglerAlign_closed :"center", - /* togglerContent_closed :"options", */ - togglerTip_closed :gettext("click to show options"), - togglerTip_open :gettext("click to hide options"), - initClosed :false, - paneSelector :".inner-north", - onopen :"onInnerNorthPaneOpen", - onclose :"onInnerNorthPaneClose" - } + north : { + // size: 66, /* 66 for FF */ + size :88, /* 66 for FF */ + spacing_closed :8, + slidable :false, + resizable :false, /* important */ + togglerLength_closed :"100%", + togglerLength_open :"100%", + togglerAlign_closed :"center", + /* togglerContent_closed :"options", */ + togglerTip_closed :gettext("click to show options"), + togglerTip_open :gettext("click to hide options"), + initClosed :false, + paneSelector :".inner-north", + onopen :"onInnerNorthPaneOpen", + onclose :"onInnerNorthPaneClose" + } }; var outerLayout, innerLayout; layoutFrames = function() { - var innerNorthPaneOpened = $.cookie('innerNorthPaneOpened'); - myDefaultInnerLayoutSettings.north.initClosed = (innerNorthPaneOpened === null) ? (innerNorthPaneDefaults['innerNorthPaneOpened'] == '0') - : (innerNorthPaneOpened == "0"); + var innerNorthPaneOpened = $.cookie('innerNorthPaneOpened'); + myDefaultInnerLayoutSettings.north.initClosed = (innerNorthPaneOpened === null) ? (innerNorthPaneDefaults['innerNorthPaneOpened'] == '0') + : (innerNorthPaneOpened == "0"); - outerLayout = $('body').layout(myDefaultOuterLayoutSettings); - innerLayout = $('div.outer-center').layout(myDefaultInnerLayoutSettings); - - // to trigger add_comment_btn positioning - if (myDefaultInnerLayoutSettings.north.initClosed) - onInnerNorthPaneClose() ; - else - onInnerNorthPaneOpen() ; + outerLayout = $('body').layout(myDefaultOuterLayoutSettings); + innerLayout = $('div.outer-center').layout(myDefaultInnerLayoutSettings); + + // to trigger add_comment_btn positioning + if (myDefaultInnerLayoutSettings.north.initClosed) + onInnerNorthPaneClose() ; + else + onInnerNorthPaneOpen() ; } fillFilterTab = function() { - - var tab = $('#c_filter'); - - var html = '
    ' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
    ' + - gettext('Text') + - ' ' + - '' + - '' + - '
    ' + - '' + - '' + - '
    ' + - '
    ' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
    ' + - gettext('Authors') + - ' ' + - '' + - ' ' + - gettext('States') + - ' ' + - '' + - '
    ' + - gettext('Dates') + - ' ' + - '' + - ' ' + - gettext('Tags') + - ' ' + - '' + - '
    '; - tab.append($(html)); - - $("#c_filter input[type='text']").add("#c_filter select").addClass('c_filter_field') ; + + var tab = $('#c_filter'); + + var html = '
    ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    ' + + gettext('Text') + + ' ' + + '' + + '' + + '
    ' + + '' + + '' + + '
    ' + + '
    ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    ' + + gettext('Authors') + + ' ' + + '' + + ' ' + + gettext('States') + + ' ' + + '' + + '
    ' + + gettext('Dates') + + ' ' + + '' + + ' ' + + gettext('Tags') + + ' ' + + '' + + '
    '; + tab.append($(html)); + + $("#c_filter input[type='text']").add("#c_filter select").addClass('c_filter_field') ; - $("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_state").change(function() { - if (frames['text_view_comments'].readyForAction()) { - var elt = $(this) ; - frames['text_view_comments'].checkForOpenedDialog(null, function() { - //console.info($(this)) ; - //console.info(elt) ; - //applyFilter($(this)) ; - applyFilter(elt) ; - }) ; - } - }); + $("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_state").change(function() { + if (frames['text_view_comments'].readyForAction()) { + var elt = $(this) ; + frames['text_view_comments'].checkForOpenedDialog(null, function() { + //console.info($(this)) ; + //console.info(elt) ; + //applyFilter($(this)) ; + applyFilter(elt) ; + }) ; + } + }); - $("#c_filter_btn").click(function() { - if (frames['text_view_comments'].readyForAction()) { - var elt = $("#filter_text") ; - frames['text_view_comments'].checkForOpenedDialog(null, function() { - applyFilter(elt) ; - }) ; - } - }); + $("#c_filter_btn").click(function() { + if (frames['text_view_comments'].readyForAction()) { + var elt = $("#filter_text") ; + frames['text_view_comments'].checkForOpenedDialog(null, function() { + applyFilter(elt) ; + }) ; + } + }); - $('#filter_text').keyup( function(e) { - if (e.keyCode == 13) {$("#c_filter_btn").click();} - }); + $('#filter_text').keyup( function(e) { + if (e.keyCode == 13) {$("#c_filter_btn").click();} + }); - $("#c_filterreset_btn").click( function() { - if (frames['text_view_comments'].readyForAction()) { - frames['text_view_comments'].checkForOpenedDialog(null, function() { - resetFilter(); - }) ; - } - }); + $("#c_filterreset_btn").click( function() { + if (frames['text_view_comments'].readyForAction()) { + frames['text_view_comments'].checkForOpenedDialog(null, function() { + resetFilter(); + }) ; + } + }); - $("#c_filterhideall_btn").click( function() { - if (frames['text_view_comments'].readyForAction()) { - frames['text_view_comments'].checkForOpenedDialog(null, function() { - frames['text_view_comments'].hideAll() ; - }) ; - } - }); - + $("#c_filterhideall_btn").click( function() { + if (frames['text_view_comments'].readyForAction()) { + frames['text_view_comments'].checkForOpenedDialog(null, function() { + frames['text_view_comments'].hideAll() ; + }) ; + } + }); + } fillTopToolbar = function() { - - var parent = $('#outer-north'); + + var parent = $('#outer-north'); - var viewPrev = gettext('view previous comment') ; - var viewNext = gettext('view next comment') ; - var viewFirst = gettext('view first comment') ; - var viewLast = gettext('view last next comment') ; - var viewAll = gettext('view all comments') ; - var viewScopeRemoved = gettext('view all detached comments') ; - var advancedInterface = gettext('toggle advance interface') ; - var print = gettext('print document with/without comments') ; - var exportDoc = gettext('export document with/without comments') ; - var fullscreen = gettext('toggle full screen view') ; - var feed = gettext('text feed') ; - var addComment = gettext('add a comment') ; + var viewPrev = gettext('view previous comment') ; + var viewNext = gettext('view next comment') ; + var viewFirst = gettext('view first comment') ; + var viewLast = gettext('view last next comment') ; + var viewAll = gettext('view all comments') ; + var viewScopeRemoved = gettext('view all detached comments') ; + var advancedInterface = gettext('toggle advance interface') ; + var print = gettext('print document with/without comments') ; + var exportDoc = gettext('export document with/without comments') ; + var fullscreen = gettext('toggle full screen view') ; + var feed = gettext('text feed') ; + var addComment = gettext('add a comment') ; - var html = '
    ' + - ''+ fullscreen +'' + - ''+ print +'' + - ''+ exportDoc +'' + - ''+ feed +'' + - '
    ' + - '
    ' + - '
    ' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
    ' + - '' + - '  ' + - ' (' + gettext('filter:') + ' /  /)' + - '' + - '' + - '' + - ', ' + gettext('browse by:') + ' ' + - '' + - '' + - '' + - ''+ viewFirst +'' + - ''+ viewPrev +'' + - '' + - '-' + - '' + - '/' + - '' + - '' + - ''+ viewNext +'' + - ''+ viewLast +'' + - '' + - ''+ viewAll +'' + - '' + - ''+ viewScopeRemoved +'' + - '' + - ''+ advancedInterface +'' + - '' + - '' + - '
    ' ; - parent.prepend($(html)); + var html = '
    ' + + ''+ fullscreen +'' + + ''+ print +'' + + ''+ exportDoc +'' + + ''+ feed +'' + + '
    ' + + '
    ' + + '
    ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    ' + + '' + + '  ' + + ' (' + gettext('filter:') + ' /  /)' + + '' + + '' + + '' + + ', ' + gettext('browse by:') + ' ' + + '' + + '' + + '' + + ''+ viewFirst +'' + + ''+ viewPrev +'' + + '' + + '-' + + '' + + '/' + + '' + + '' + + ''+ viewNext +'' + + ''+ viewLast +'' + + '' + + ''+ viewAll +'' + + '' + + ''+ viewScopeRemoved +'' + + '' + + ''+ advancedInterface +'' + + '' + + '' + + '
    ' ; + parent.prepend($(html)); - $("#add_comment_btn").click( function() { - if (frames['text_view_comments'].readyForAction()) { - frames['text_view_comments'].checkForOpenedDialog(null, function() { - frames['text_view_comments'].gSync.showCommentForm(null) ; - }) ; - } - }); + $("#add_comment_btn").click( function() { + if (frames['text_view_comments'].readyForAction()) { + frames['text_view_comments'].checkForOpenedDialog(null, function() { + frames['text_view_comments'].gSync.showCommentForm(null) ; + }) ; + } + }); - var showBrowseIndx = function() { - $("#browse_by option").each(function() { - $("#c_browse_indx_"+this.value).hide() ; - }) ; - $('#c_browse_indx_' + $('#browse_by').val()).show() ; - }; - - var first_browse_by_val = $.cookie('browse_by'); - first_browse_by_val = (first_browse_by_val == null) ? "location" : first_browse_by_val ; - _setCookie('browse_by', $('#browse_by').val()); - $("#browse_by option[value="+ first_browse_by_val +"]").attr("selected", true); - showBrowseIndx() ; - - $("#browse_by").change(function() { - _setCookie('browse_by', $('#browse_by').val()); - showBrowseIndx() ; - }); - - var lBrowse = function(whereto) { - if (frames['text_view_comments'].readyForAction()) - frames['text_view_comments'].checkForOpenedDialog(null, function() { - frames['text_view_comments'].browse($('#browse_by').val(), whereto); - }) ; - }; - $("#c_browse_prev").click( function() {lBrowse("prev");}); - $("#c_browse_next").click( function() {lBrowse("next");}); - $("#c_browse_first").click( function() {lBrowse("first");}); - $("#c_browse_last").click( function() {lBrowse("last");}); - $("#c_browse_all").click( function() { - if (frames['text_view_comments'].readyForAction()) { - frames['text_view_comments'].checkForOpenedDialog(null, function() { - frames['text_view_comments'].gSync.showAllComments() ; - }) ; - } - }); - - $("#c_browse_scope_removed").click( function() { - if (frames['text_view_comments'].readyForAction()) { - frames['text_view_comments'].checkForOpenedDialog(null, function() { - frames['text_view_comments'].gSync.showScopeRemovedComments() ; - }) ; - } - }); - - $("#c_print_btn").click( function() { - if (frames['text_view_comments'].readyForAction()) { - var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ; - frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ; - openPrintDialog() ; - } - }); - - $("#c_export_btn").click( function() { - if (frames['text_view_comments'].readyForAction()) { - var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ; - frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ; - openExportDialog() ; - } - }); - - if (frames['text_view_comments'].gLayout.isInComentSite()) { - $("#c_fullscreen_btn").click( function() { - toggleFrameSize(); - }); - } ; - - $("#c_advanced_btn").click( function() { - $('.ui-layout-toggler').click() ; // calling the layout method did not work well edo that instead - }) ; - - setThreadPref = function() { - var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad'); + var showBrowseIndx = function() { + $("#browse_by option").each(function() { + $("#c_browse_indx_"+this.value).hide() ; + }) ; + $('#c_browse_indx_' + $('#browse_by').val()).show() ; + }; + + var first_browse_by_val = $.cookie('browse_by'); + first_browse_by_val = (first_browse_by_val == null) ? "location" : first_browse_by_val ; + _setCookie('browse_by', $('#browse_by').val()); + $("#browse_by option[value="+ first_browse_by_val +"]").attr("selected", true); + showBrowseIndx() ; + + $("#browse_by").change(function() { + _setCookie('browse_by', $('#browse_by').val()); + showBrowseIndx() ; + }); + + var lBrowse = function(whereto) { + if (frames['text_view_comments'].readyForAction()) + frames['text_view_comments'].checkForOpenedDialog(null, function() { + frames['text_view_comments'].browse($('#browse_by').val(), whereto); + }) ; + }; + $("#c_browse_prev").click( function() {lBrowse("prev");}); + $("#c_browse_next").click( function() {lBrowse("next");}); + $("#c_browse_first").click( function() {lBrowse("first");}); + $("#c_browse_last").click( function() {lBrowse("last");}); + $("#c_browse_all").click( function() { + if (frames['text_view_comments'].readyForAction()) { + frames['text_view_comments'].checkForOpenedDialog(null, function() { + frames['text_view_comments'].gSync.showAllComments() ; + }) ; + } + }); + + $("#c_browse_scope_removed").click( function() { + if (frames['text_view_comments'].readyForAction()) { + frames['text_view_comments'].checkForOpenedDialog(null, function() { + frames['text_view_comments'].gSync.showScopeRemovedComments() ; + }) ; + } + }); + + $("#c_print_btn").click( function() { + if (frames['text_view_comments'].readyForAction()) { + var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ; + frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ; + openPrintDialog() ; + } + }); + + $("#c_export_btn").click( function() { + if (frames['text_view_comments'].readyForAction()) { + var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ; + frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ; + openExportDialog() ; + } + }); + + if (frames['text_view_comments'].gLayout.isInComentSite()) { + $("#c_fullscreen_btn").click( function() { + toggleFrameSize(); + }); + } ; + + $("#c_advanced_btn").click( function() { + $('.ui-layout-toggler').click() ; // calling the layout method did not work well edo that instead + }) ; + + setThreadPref = function() { + var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad'); - var btn_src = sv_media_url + '/img/unthread_box.png' ; - var btn_desc = gettext('unthread discussions') ; - if (v == '0') { - btn_src = sv_media_url + '/img/thread_box.png' ; - btn_desc = gettext('thread discussions') ; - } - $('#c_thread_unthread_img').attr('src', btn_src).attr('alt', btn_desc).attr('title', btn_desc) ; - }; - - setThreadPref(); - $('#c_thread_unthread').click( function() { - var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad'); - var anti_v = (v == '0') ? '1' : '0'; - frames['text_view_comments'].c_persistPreference('comments', 'threadpad', anti_v); - setThreadPref(); - frames['text_view_comments'].gSync.animateToTop() ; - }); - + var btn_src = sv_media_url + '/img/unthread_box.png' ; + var btn_desc = gettext('unthread discussions') ; + if (v == '0') { + btn_src = sv_media_url + '/img/thread_box.png' ; + btn_desc = gettext('thread discussions') ; + } + $('#c_thread_unthread_img').attr('src', btn_src).attr('alt', btn_desc).attr('title', btn_desc) ; + }; + + setThreadPref(); + $('#c_thread_unthread').click( function() { + var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad'); + var anti_v = (v == '0') ? '1' : '0'; + frames['text_view_comments'].c_persistPreference('comments', 'threadpad', anti_v); + setThreadPref(); + frames['text_view_comments'].gSync.animateToTop() ; + }); + } onSliderStop = function() { - var slideVal = $("#c_slider").slider('value') ; -// console.info("in onSliderStop slider val : " + slideVal) ; - if (slideVal > (frames['text_view_comments'].gConf['sliderFixedMin'] * 100)) - $("#c_slider").slider('value', [90]) ; - if (slideVal < (frames['text_view_comments'].gConf['sliderFixedMax'] * 100)) - $("#c_slider").slider('value', [10]) ; - - frames['text_view_comments'].c_setCommentsColWidth(slideVal) ; - frames['text_view_comments'].c_persistPreference('layout', 'comments_col_width', slideVal); + var slideVal = $("#c_slider").slider('value') ; +// console.info("in onSliderStop slider val : " + slideVal) ; + if (slideVal > (frames['text_view_comments'].gConf['sliderFixedMin'] * 100)) + $("#c_slider").slider('value', [90]) ; + if (slideVal < (frames['text_view_comments'].gConf['sliderFixedMax'] * 100)) + $("#c_slider").slider('value', [10]) ; + + frames['text_view_comments'].c_setCommentsColWidth(slideVal) ; + frames['text_view_comments'].c_persistPreference('layout', 'comments_col_width', slideVal); } fillTextPreferencesTab = function() { - var tab = $('#c_text_preferences'); - tab.append($( - '' + - '' + - '' + - '' + - '' + - '' + - '
    ' + - gettext('Text style') + - ' ' + - '' + - '
    ')) ; - var styles = frames['text_view_comments'].gTextStyles ; - for (var key in styles) { - $("#c_textpref_style").append($("")) ; - } - - var setTextStyle = function() { - var styles = frames['text_view_comments'].gTextStyles ; - var wish = $('#c_textpref_style').val() ; - for (var key in styles) { - if (key == wish) - frames['text_view_comments'].CY.get("#textcontainer").addClass(styles[key]) ; - else - frames['text_view_comments'].CY.get("#textcontainer").removeClass(styles[key]) ; - } - }; - - var setTextStyleField = function() { - var v = frames['text_view_comments'].c_readPreference('text', 'style'); - $('#c_textpref_style').val(v); - }; - - $("#c_textpref_style").change(function(v) { - frames['text_view_comments'].c_persistPreference('text', 'style', $("#c_textpref_style").val()); - setTextStyle(); - }); - - setTextStyleField(); - setTextStyle(); + var tab = $('#c_text_preferences'); + tab.append($( + '' + + '' + + '' + + '' + + '' + + '' + + '
    ' + + gettext('Text style') + + ' ' + + '' + + '
    ')) ; + var styles = frames['text_view_comments'].gTextStyles ; + for (var key in styles) { + $("#c_textpref_style").append($("")) ; + } + + var setTextStyle = function() { + var styles = frames['text_view_comments'].gTextStyles ; + var wish = $('#c_textpref_style').val() ; + for (var key in styles) { + if (key == wish) + frames['text_view_comments'].CY.get("#textcontainer").addClass(styles[key]) ; + else + frames['text_view_comments'].CY.get("#textcontainer").removeClass(styles[key]) ; + } + }; + + var setTextStyleField = function() { + var v = frames['text_view_comments'].c_readPreference('text', 'style'); + $('#c_textpref_style').val(v); + }; + + $("#c_textpref_style").change(function(v) { + frames['text_view_comments'].c_persistPreference('text', 'style', $("#c_textpref_style").val()); + setTextStyle(); + }); + + setTextStyleField(); + setTextStyle(); } fillPreferencesTab = function() { - var tab = $('#c_preferences'); + var tab = $('#c_preferences'); - var html = '
    ' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
    ' + - gettext('Animation duration') + - ' ' + - '' + - '
    ' + - '' + gettext('(0.001 to 1 second)') + '' + - '
    '; - tab.append($(html)) ; + var html = '
    ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    ' + + gettext('Animation duration') + + ' ' + + '' + + '
    ' + + '' + gettext('(0.001 to 1 second)') + '' + + '
    '; + tab.append($(html)) ; - setPreferencesFieldsValue = function() { - var v = frames['text_view_comments'].c_readPreference('general', 'animduration'); - $('#c_pref_animduration').val(v); - }; - - setPreferencesFieldsValue(); + setPreferencesFieldsValue = function() { + var v = frames['text_view_comments'].c_readPreference('general', 'animduration'); + $('#c_pref_animduration').val(v); + }; + + setPreferencesFieldsValue(); - $('#c_pref_animduration').blur( function() { - var v = parseFloat($(this).val()); - if (isNaN(v) || (v <= 0) || (v > 1)) { - v = frames['text_view_comments'].c_readDefaultPreference('general', 'animduration'); - } - $(this).val(v); - }); + $('#c_pref_animduration').blur( function() { + var v = parseFloat($(this).val()); + if (isNaN(v) || (v <= 0) || (v > 1)) { + v = frames['text_view_comments'].c_readDefaultPreference('general', 'animduration'); + } + $(this).val(v); + }); - $('#c_pref_reset_btn').click( function() { - frames['text_view_comments'].c_resetPreferences(['general']); - setPreferencesFieldsValue(); + $('#c_pref_reset_btn').click( function() { + frames['text_view_comments'].c_resetPreferences(['general']); + setPreferencesFieldsValue(); - enqueueMsg(gettext('preferences reset (will apply on next load)')); - }); + enqueueMsg(gettext('preferences reset (will apply on next load)')); + }); - $('#c_pref_save_btn').click( function() { - frames['text_view_comments'].c_persistPreference('general', 'animduration', $('#c_pref_animduration').val()); + $('#c_pref_save_btn').click( function() { + frames['text_view_comments'].c_persistPreference('general', 'animduration', $('#c_pref_animduration').val()); - enqueueMsg(gettext('preferences saved (will apply on next load)')); - }); + enqueueMsg(gettext('preferences saved (will apply on next load)')); + }); } initFrame = function() { - _initYesNoDialog(); - _initPrintDialog() ; + _initYesNoDialog(); + _initPrintDialog() ; - $(window).resize(function(){ - onSliderStop(); -// console.log('in frame resize' + $("#c_slider").slider('value')) ; -// console.log('in frame resize' + frames['text_view_comments'].CY.DOM.winWidth()) ; -// console.log('in frame resize' + $(window).width()) ; - }); + $(window).resize(function(){ + onSliderStop(); +// console.log('in frame resize' + $("#c_slider").slider('value')) ; +// console.log('in frame resize' + frames['text_view_comments'].CY.DOM.winWidth()) ; +// console.log('in frame resize' + $(window).width()) ; + }); - //$('
    ').appendTo("#c-btns").slider({ - $('#c_slider').slider({ - animate: true, - range: "min", - value: frames['text_view_comments'].c_readPreference('layout','comments_col_width'), - min: 1, - iframeFix: true, - max: 100, -// step: 5, - slide: function(event, ui) { - var slideVal = ui.value ; - frames['text_view_comments'].c_setCommentsColWidth(slideVal) ; - }, - stop:function(event, ui) { - onSliderStop() ; - } - }) ; + //$('
    ').appendTo("#c-btns").slider({ + $('#c_slider').slider({ + animate: true, + range: "min", + value: frames['text_view_comments'].c_readPreference('layout','comments_col_width'), + min: 1, + iframeFix: true, + max: 100, +// step: 5, + slide: function(event, ui) { + var slideVal = ui.value ; + frames['text_view_comments'].c_setCommentsColWidth(slideVal) ; + }, + stop:function(event, ui) { + onSliderStop() ; + } + }) ; - - _initTabs(); - - f_interfaceFreeze(); + + _initTabs(); + + f_interfaceFreeze(); }; _initTabs = function() { - $(".inner-north").tabs(); + $(".inner-north").tabs(); - var selectedTab = $.cookie('selectedTab'); - selectedTab = (selectedTab === null) ? innerNorthPaneDefaults['selectedTab'] : parseInt(selectedTab); - $(".inner-north").tabs('select', selectedTab); - $(".inner-north").bind('tabsselect', function(event, ui) { - // // Objects available in the function context: - // ui.tab // anchor element of the selected (clicked) tab - // ui.panel // element, that contains the selected/clicked tab - // contents - // ui.index // zero-based index of the selected (clicked) tab - _setCookie('selectedTab', ui.index); + var selectedTab = $.cookie('selectedTab'); + selectedTab = (selectedTab === null) ? innerNorthPaneDefaults['selectedTab'] : parseInt(selectedTab); + $(".inner-north").tabs('select', selectedTab); + $(".inner-north").bind('tabsselect', function(event, ui) { + // // Objects available in the function context: + // ui.tab // anchor element of the selected (clicked) tab + // ui.panel // element, that contains the selected/clicked tab + // contents + // ui.index // zero-based index of the selected (clicked) tab + _setCookie('selectedTab', ui.index); - }); + }); } _initYesNoDialog = function() { - $('#dialog_h').dialog( { - // bgiframe: true, // why would we ? - autoOpen :false, - modal :true - }); + $('#dialog_h').dialog( { + // bgiframe: true, // why would we ? + autoOpen :false, + modal :true + }); } _setCookie = function(name, value) { - var cookieExpire = new Date(); - cookieExpire.setFullYear(2100, 0, 1); - $.cookie(name, value, { - 'expires' :cookieExpire, - 'path': '/' - }); + var cookieExpire = new Date(); + cookieExpire.setFullYear(2100, 0, 1); + $.cookie(name, value, { + 'expires' :cookieExpire, + 'path': '/' + }); } //contains code thats offered by the text_view_comment_frame to its child frame text_view_comment f_getFrameFilterData = function () { - var name = $('#filter_name').val(); ; - var date_str = $('#filter_date').val(); ; - var text = $('#filter_text').val(); ; - var tag = $('#filter_tag').val(); ; - var state = $('#filter_state').val(); ; - return {'name':name, 'date':date_str, 'text':text, 'tag':tag, 'state':state} ; + var name = $('#filter_name').val(); ; + var date_str = $('#filter_date').val(); ; + var text = $('#filter_text').val(); ; + var tag = $('#filter_tag').val(); ; + var state = $('#filter_state').val(); ; + return {'name':name, 'date':date_str, 'text':text, 'tag':tag, 'state':state} ; } f_setFilterValue = function (obj) { - for (key in obj) { - if (key.indexOf('filter_') == 0) - $('#'+key).val(obj[key]); // wont explode even if argument is silly - } + for (key in obj) { + if (key.indexOf('filter_') == 0) + $('#'+key).val(obj[key]); // wont explode even if argument is silly + } } f_isFrameFilterFieldsInit = function () { - var obj = f_getFrameFilterData() ; - var ret = true ; - for (key in obj) { - ret = ret && (obj[key] == "") ; - } - return ret ; + var obj = f_getFrameFilterData() ; + var ret = true ; + for (key in obj) { + ret = ret && (obj[key] == "") ; + } + return ret ; } initFilterFields = function () { - $('.c_filter_field').val("") ; + $('.c_filter_field').val("") ; } resetFilter = function () { - initFilterFields() ; - frames['text_view_comments'].reinit() ; - enqueueMsg(gettext("filter reset")) ; + initFilterFields() ; + frames['text_view_comments'].reinit() ; + enqueueMsg(gettext("filter reset")) ; } applyFilter = function(self) { - var val = self.val() ; - if (gResetOtherFieldsOnFilterFieldChange) { - initFilterFields() ; - self.val(val) ; - } - frames['text_view_comments'].reinit(); - enqueueMsg(gettext("filter applied")); + var val = self.val() ; + if (gResetOtherFieldsOnFilterFieldChange) { + initFilterFields() ; + self.val(val) ; + } + frames['text_view_comments'].reinit(); + enqueueMsg(gettext("filter applied")); } f_updateFilterCountResult = function(nbDiscussions, nbComments, nbReplies, nbAllComments, nbAllReplies) { - // update result counter message field. - $("#c_f_res_nb_dis").html(nbDiscussions) ; - $("#c_f_res_nb_dis_txt").html(ngettext('discussion', 'discussions', nbDiscussions)) ; + // update result counter message field. + $("#c_f_res_nb_dis").html(nbDiscussions) ; + $("#c_f_res_nb_dis_txt").html(ngettext('discussion', 'discussions', nbDiscussions)) ; - $("#c_f_res_nb_com").html(nbComments) ; - $("#c_f_res_nb_tot_com").html(nbAllComments) ; - $("#c_f_res_nb_com_txt").html(ngettext('comment', 'comments', nbComments)) ; - $("#c_f_res_nb_rep").html(nbReplies) ; - $("#c_f_res_nb_tot_rep").html(nbAllReplies) ; - $("#c_f_res_nb_rep_txt").html(' ' + ngettext('reply', 'replies', nbReplies)) ; + $("#c_f_res_nb_com").html(nbComments) ; + $("#c_f_res_nb_tot_com").html(nbAllComments) ; + $("#c_f_res_nb_com_txt").html(ngettext('comment', 'comments', nbComments)) ; + $("#c_f_res_nb_rep").html(nbReplies) ; + $("#c_f_res_nb_tot_rep").html(nbAllReplies) ; + $("#c_f_res_nb_rep_txt").html(' ' + ngettext('reply', 'replies', nbReplies)) ; - // update browser infos - $("#c_browse_indx_total").html(nbDiscussions) ; - - //console.info('nbDiscussions + typeof nbDiscussions +nbComments + typeof nbComments) ; - $("#c_filter_results").show() ; + // update browser infos + $("#c_browse_indx_total").html(nbDiscussions) ; + + //console.info('nbDiscussions + typeof nbDiscussions +nbComments + typeof nbComments) ; + $("#c_filter_results").show() ; } ; f_updateFilterCountDetailed = function(detailed) { - if (detailed) { - $("#c_f_res_details").show() ; - $("c_browse_all").val('View all (filtered) comments') - } - else { - $("#c_f_res_details").hide() ; - $("#c_browse_all").val('View all comments') - } + if (detailed) { + $("#c_f_res_details").show() ; + $("c_browse_all").val('View all (filtered) comments') + } + else { + $("#c_f_res_details").hide() ; + $("#c_browse_all").val('View all comments') + } } ; f_updateFilterData = function(newFilterData) { -// console.info(newFilterData) ; - // users - var selectedNameOption = $("#filter_name option:selected").attr("name") ; - var all = gettext("all") ; - $("#filter_name option").remove() ; - - $("#filter_name").append($("")) ; - for (var i=0, ilen=newFilterData['names'].length; i < ilen ; i++) { - var item = newFilterData['names'][i] ; - $("#filter_name").append($("")) ; - } - - $("#filter_name option[name="+selectedNameOption+"]").attr("selected", true); - - // dates - var selectedDateOption = $("#filter_date option:selected").attr("name") ; +// console.info(newFilterData) ; + // users + var selectedNameOption = $("#filter_name option:selected").attr("name") ; + var all = gettext("all") ; + $("#filter_name option").remove() ; + + $("#filter_name").append($("")) ; + for (var i=0, ilen=newFilterData['names'].length; i < ilen ; i++) { + var item = newFilterData['names'][i] ; + $("#filter_name").append($("")) ; + } + + $("#filter_name option[name="+selectedNameOption+"]").attr("selected", true); + + // dates + var selectedDateOption = $("#filter_date option:selected").attr("name") ; - $("#filter_date option").remove() ; - - $("#filter_date").append($("")) ; - for (var i=0, ilen=newFilterData['dates'].length; i < ilen ; i++) { - var item = newFilterData['dates'][i] ; - var ddd = ngettext('last 24 hours (%(nb_comments)s)', 'last %(nb_days)s days (%(nb_comments)s)', item.nb_day) ; - var ccc = interpolate(ddd,{'nb_days':item.nb_day, 'nb_comments':item.nb_comments}, true) ; - - $("#filter_date").append($("")) ; - } - - $("#filter_date option[name="+selectedDateOption+"]").attr("selected", true); - - // text : nothing to do - - // tags - var selectedTagOption = $("#filter_tag option:selected").attr("name") ; + $("#filter_date option").remove() ; + + $("#filter_date").append($("")) ; + for (var i=0, ilen=newFilterData['dates'].length; i < ilen ; i++) { + var item = newFilterData['dates'][i] ; + var ddd = ngettext('last 24 hours (%(nb_comments)s)', 'last %(nb_days)s days (%(nb_comments)s)', item.nb_day) ; + var ccc = interpolate(ddd,{'nb_days':item.nb_day, 'nb_comments':item.nb_comments}, true) ; + + $("#filter_date").append($("")) ; + } + + $("#filter_date option[name="+selectedDateOption+"]").attr("selected", true); + + // text : nothing to do + + // tags + var selectedTagOption = $("#filter_tag option:selected").attr("name") ; - $("#filter_tag option").remove() ; - - $("#filter_tag").append($("")) ; - for (var i=0, ilen=newFilterData['tags'].length; i < ilen ; i++) { - var item = newFilterData['tags'][i] ; - $("#filter_tag").append($("")) ; - } - $("#filter_tag option[name="+selectedTagOption+"]").attr("selected", true); - - // states - var selectedStateOption = $("#filter_state option:selected").attr("state") ; + $("#filter_tag option").remove() ; + + $("#filter_tag").append($("")) ; + for (var i=0, ilen=newFilterData['tags'].length; i < ilen ; i++) { + var item = newFilterData['tags'][i] ; + $("#filter_tag").append($("")) ; + } + $("#filter_tag option[name="+selectedTagOption+"]").attr("selected", true); + + // states + var selectedStateOption = $("#filter_state option:selected").attr("state") ; - $("#filter_state option").remove() ; - - $("#filter_state").append($("")) ; - for (var i=0, ilen=newFilterData['states'].length; i < ilen ; i++) { - var item = newFilterData['states'][i] ; - $("#filter_state").append($("")) ; - } - $("#filter_state option[name="+selectedStateOption+"]").attr("selected", true); + $("#filter_state option").remove() ; + + $("#filter_state").append($("")) ; + for (var i=0, ilen=newFilterData['states'].length; i < ilen ; i++) { + var item = newFilterData['states'][i] ; + $("#filter_state").append($("")) ; + } + $("#filter_state option[name="+selectedStateOption+"]").attr("selected", true); } ; f_interfaceUnfreeze = function() { - // tabs headers - for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) { - $(".inner-north").tabs("enable", i); - } + // tabs headers + for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) { + $(".inner-north").tabs("enable", i); + } - $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() { - $(this).attr("disabled", false); - }); + $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() { + $(this).attr("disabled", false); + }); - $("#c_slider").slider('enable') ; + $("#c_slider").slider('enable') ; } ; f_interfaceFreeze = function() { - // tabs headers - for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) { - $(".inner-north").tabs("disable", i); - } + // tabs headers + for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) { + $(".inner-north").tabs("disable", i); + } - $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() { - $(this).attr("disabled", true); - }); - - $("#c_slider").slider('disable') ; + $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() { + $(this).attr("disabled", true); + }); + + $("#c_slider").slider('disable') ; } ; f_enqueueMsg = function(msg) { - enqueueMsg(msg) ; + enqueueMsg(msg) ; } ; f_enqueueErrorMsg = function(msg) { - enqueueErrorMsg(msg) ; + enqueueErrorMsg(msg) ; } ; f_removeLoadingMsg = function() { - removeLoadingMsg() ; + removeLoadingMsg() ; } f_initFrame = function() { - initFrame() ; + initFrame() ; } f_layoutFrames = function() { - layoutFrames() ; + layoutFrames() ; } f_fillTextPreferencesTab = function() { - fillTextPreferencesTab() ; + fillTextPreferencesTab() ; } f_fillPreferencesTab = function() { - fillPreferencesTab() ; + fillPreferencesTab() ; } f_fillBrowseSection = function() { - fillBrowseSection() ; + fillBrowseSection() ; } f_fillFilterTab = function() { - fillFilterTab() ; + fillFilterTab() ; } f_fillTopToolbar = function() { - fillTopToolbar() ; + fillTopToolbar() ; } f_yesNoDialog = function(htmlContent, title, noFunction, noFunctionContext, noFunctionArgs, yesFunction, yesFunctionContext, yesFunctionArgs) { - $('#dialog_h').html(htmlContent) ; - - $('#dialog_h').dialog('option', 'title', title) ; + $('#dialog_h').html(htmlContent) ; + + $('#dialog_h').dialog('option', 'title', title) ; - function onNo() { - if (noFunction != null) - noFunction.call(noFunctionContext, noFunctionArgs) ; - } - - function onYes() { - if (yesFunction != null) - yesFunction.call(yesFunctionContext, yesFunctionArgs) ; - } - var buttons = {} ; - buttons[gettext('No')] = function() {$(this).dialog('close');onNo();} ; - buttons[gettext('Yes')] = function() {$(this).dialog('close');onYes();} ; - $('#dialog_h').dialog('option', 'buttons', buttons) ; - $('#dialog_h').dialog('open') ; + function onNo() { + if (noFunction != null) + noFunction.call(noFunctionContext, noFunctionArgs) ; + } + + function onYes() { + if (yesFunction != null) + yesFunction.call(yesFunctionContext, yesFunctionArgs) ; + } + var buttons = {} ; + buttons[gettext('No')] = function() {$(this).dialog('close');onNo();} ; + buttons[gettext('Yes')] = function() {$(this).dialog('close');onYes();} ; + $('#dialog_h').dialog('option', 'buttons', buttons) ; + $('#dialog_h').dialog('open') ; } f_setCookie = function(name, value) { - _setCookie(name, value) ; + _setCookie(name, value) ; } @@ -758,83 +758,83 @@ gInFullScreen = false; _setFrameSize = function() { - if (parent != window) { // (this condition is to enable accessing "comments_frame" view from top window) TODO test under IE - if (gInFullScreen) { - var headerHeight = parent.$("#header").height(); - var windowHeight = parent.$(parent).height(); - var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2 - - var windowWidth = parent.$(parent).width(); - var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2 - - // TODO we should be embeded ! shouldn't work otherwise anyway (frame security concerns) - parent.$("#text_view_frame").css( { - 'position' :'absolute', - 'left' :'0px', - 'top' :headerHeight, - 'width' :frameWidth, - 'height' :frameHeight - }); - } - else { - var frameTop = Math.ceil(parent.$("#autoexpand_text_view_frame_container").position()["top"]); - - var windowHeight = parent.$(parent).height(); - var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2 - - var windowWidth = parent.$(parent).width(); - var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2 - - // TODO test if we're embeded ! wont work otherwise anyway (frame security) - parent.$("#text_view_frame").css( { - 'position' :'relative', - 'width' :'99.9%', - 'height' :frameHeight, - 'top' :'0px' - }); - } - } + if (parent != window) { // (this condition is to enable accessing "comments_frame" view from top window) TODO test under IE + if (gInFullScreen) { + var headerHeight = parent.$("#header").height(); + var windowHeight = parent.$(parent).height(); + var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2 + + var windowWidth = parent.$(parent).width(); + var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2 + + // TODO we should be embeded ! shouldn't work otherwise anyway (frame security concerns) + parent.$("#text_view_frame").css( { + 'position' :'absolute', + 'left' :'0px', + 'top' :headerHeight, + 'width' :frameWidth, + 'height' :frameHeight + }); + } + else { + var frameTop = Math.ceil(parent.$("#autoexpand_text_view_frame_container").position()["top"]); + + var windowHeight = parent.$(parent).height(); + var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2 + + var windowWidth = parent.$(parent).width(); + var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2 + + // TODO test if we're embeded ! wont work otherwise anyway (frame security) + parent.$("#text_view_frame").css( { + 'position' :'relative', + 'width' :'99.9%', + 'height' :frameHeight, + 'top' :'0px' + }); + } + } } _toFullScreenSize = function() { - gInFullScreen = true; - _setFrameSize() ; + gInFullScreen = true; + _setFrameSize() ; - $("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png'); + $("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png'); - f_setCookie('fullscreen', '1') ; + f_setCookie('fullscreen', '1') ; }; _toNormalSize = function() { - gInFullScreen = false; - _setFrameSize() ; + gInFullScreen = false; + _setFrameSize() ; - $("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png'); - - f_setCookie('fullscreen', '0') ; + $("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png'); + + f_setCookie('fullscreen', '0') ; }; _toInitialSize = function() { - //console.info('_toInitialSize') ; - var fullscreen = ($.cookie('fullscreen') == '1'); - if (fullscreen) - _toFullScreenSize() ; - else - _toNormalSize() ; + //console.info('_toInitialSize') ; + var fullscreen = ($.cookie('fullscreen') == '1'); + if (fullscreen) + _toFullScreenSize() ; + else + _toNormalSize() ; }; toInitialSize = function() { - _toInitialSize() ; - parent.$(parent).resize(function(){ -// console.log('before setFramesize in top resize winwidth' + frames['text_view_comments'].CY.DOM.winWidth()) ; - _setFrameSize(); -// console.log('after setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; - }); + _toInitialSize() ; + parent.$(parent).resize(function(){ +// console.log('before setFramesize in top resize winwidth' + frames['text_view_comments'].CY.DOM.winWidth()) ; + _setFrameSize(); +// console.log('after setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; + }); } toggleFrameSize = function() { - if (gInFullScreen) - _toNormalSize() ; - else - _toFullScreenSize() ; + if (gInFullScreen) + _toNormalSize() ; + else + _toFullScreenSize() ; } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/layout/base.js --- a/src/cm/media/js/site/layout/base.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/layout/base.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,55 +1,55 @@ // this == dom element onFadeEnd = function () { - $(this).remove() ; + $(this).remove() ; } ; _enqueueMsg = function(msg, cls, remainVisibleTime) { - var m = $('' + msg + '').addClass("f-msg-cls").addClass(cls).appendTo("#t-msg-wrapper") ; - if (remainVisibleTime) - m.parent().animate({'opacity':.95}, remainVisibleTime).fadeOut(2000, onFadeEnd) ; - return m ; - + var m = $('' + msg + '').addClass("f-msg-cls").addClass(cls).appendTo("#t-msg-wrapper") ; + if (remainVisibleTime) + m.parent().animate({'opacity':.95}, remainVisibleTime).fadeOut(2000, onFadeEnd) ; + return m ; + } enqueueMsg = function(msg) { - var cls = "f-msg" ; - var remainVisibleTime = 2000 ; - _enqueueMsg(msg, cls, remainVisibleTime) ; + var cls = "f-msg" ; + var remainVisibleTime = 2000 ; + _enqueueMsg(msg, cls, remainVisibleTime) ; } enqueueErrorMsg = function(msg) { - var cls = "f-msg-e" ; - var remainVisibleTime = 4000 ; - _enqueueMsg(msg, cls, remainVisibleTime) ; + var cls = "f-msg-e" ; + var remainVisibleTime = 4000 ; + _enqueueMsg(msg, cls, remainVisibleTime) ; } setCookie = function(name, value) { - var cookieExpire = new Date(); - cookieExpire.setFullYear(2100, 0, 1); - $.cookie(name, value, { - 'expires' :cookieExpire, - 'path': '/' - }); + var cookieExpire = new Date(); + cookieExpire.setFullYear(2100, 0, 1); + $.cookie(name, value, { + 'expires' :cookieExpire, + 'path': '/' + }); } /* utility function to remember form field value into cookie */ rememberFormField = function(form_id, field_id, cookie_name) { - /* value gets fetched from cookie if possible */ - $(document).ready(function(){ - var cookie_val = $.cookie(cookie_name); - if (cookie_val) { - $('#' + form_id + ' #' + field_id)[0].value = cookie_val; - } - }) + /* value gets fetched from cookie if possible */ + $(document).ready(function(){ + var cookie_val = $.cookie(cookie_name); + if (cookie_val) { + $('#' + form_id + ' #' + field_id)[0].value = cookie_val; + } + }) - /* value gets saved on submit */ - $(document).ready(function(){ - $('#' + form_id + ' input[type=submit]').click(function() { - var val = $('#' + form_id + ' #' + field_id)[0].value; - if (val) { - setCookie(cookie_name, val); - } - }); - }) + /* value gets saved on submit */ + $(document).ready(function(){ + $('#' + form_id + ' input[type=submit]').click(function() { + var val = $('#' + form_id + ' #' + field_id)[0].value; + if (val) { + setCookie(cookie_name, val); + } + }); + }) } diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/text_edit.js --- a/src/cm/media/js/site/text_edit.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/text_edit.js Tue Nov 30 09:53:35 2010 +0100 @@ -21,37 +21,37 @@ nb_removed = obj['nb_removed']; if (newVersion) { if (nb_removed == 0) { - submit_edit_form(); + submit_edit_form(); } else { - var message = ngettext( - '%(nb_comments)s comment applies to text that was modified.', - '%(nb_comments)s comments apply to text that was modified.', - nb_removed) ; - message += '
    ' ; - message += mess ; - message = interpolate(message,{'nb_comments':nb_removed}, true) ; - + var message = ngettext( + '%(nb_comments)s comment applies to text that was modified.', + '%(nb_comments)s comments apply to text that was modified.', + nb_removed) ; + message += '
    ' ; + message += mess ; + message = interpolate(message,{'nb_comments':nb_removed}, true) ; + $('#remove_scope_choice_dlg').html(message) ; $('#remove_scope_choice_dlg').dialog('open') ; } } else { if (nb_removed == 0) { - submit_edit_form(); + submit_edit_form(); } else { - var message = ngettext( - '%(nb_comments)s comment applies to text that was modified.', - '%(nb_comments)s comments apply to text that was modified.', - nb_removed) ; - message += '
    ' ; - message += gettext( '(We suggest you create a new version)') ; - message += '
    ' ; - message += mess ; - message = interpolate(message,{'nb_comments':nb_removed}, true) ; + var message = ngettext( + '%(nb_comments)s comment applies to text that was modified.', + '%(nb_comments)s comments apply to text that was modified.', + nb_removed) ; + message += '
    ' ; + message += gettext( '(We suggest you create a new version)') ; + message += '
    ' ; + message += mess ; + message = interpolate(message,{'nb_comments':nb_removed}, true) ; - $('#remove_scope_choice_dlg').html(message) ; + $('#remove_scope_choice_dlg').html(message) ; $('#remove_scope_choice_dlg').dialog('open') ; } } @@ -63,32 +63,32 @@ } else { if (!newVersion) { - + var message = gettext("You chose not to create a new version all comments will be deleted") ; - message += '
    ' ; - message += gettext( 'Do you want to continue?') ; + message += '
    ' ; + message += gettext( 'Do you want to continue?') ; $('#confirm_all_removed_dlg').html(message) ; $('#confirm_all_removed_dlg').dialog('open') ; } else { - submit_edit_form() ; + submit_edit_form() ; } } } function submit_edit_form() { - needToConfirm = false; + needToConfirm = false; $('#edit_form').submit(); } $(function() { - var buttons = {}; - buttons[gettext('No')] = function() { - $(this).dialog('close'); - } ; - buttons[gettext('Yes')] = function() { - $(this).dialog('close');submit_edit_form(); - } ; + var buttons = {}; + buttons[gettext('No')] = function() { + $(this).dialog('close'); + } ; + buttons[gettext('Yes')] = function() { + $(this).dialog('close');submit_edit_form(); + } ; $('#confirm_all_removed_dlg').dialog({ bgiframe: true, @@ -98,10 +98,10 @@ buttons:buttons }) ; - var buttons0 = {}; - buttons0[gettext('Detach')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("1");submit_edit_form();} ; - buttons0[gettext('Remove')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("0");submit_edit_form();} ; - buttons0[gettext('Cancel')] = function() {$(this).dialog('close');} ; + var buttons0 = {}; + buttons0[gettext('Detach')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("1");submit_edit_form();} ; + buttons0[gettext('Remove')] = function() {$(this).dialog('close');$('#cancel_modified_scopes').val("0");submit_edit_form();} ; + buttons0[gettext('Cancel')] = function() {$(this).dialog('close');} ; $('#remove_scope_choice_dlg').dialog({ bgiframe: true, diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/text_view.js --- a/src/cm/media/js/site/text_view.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/text_view.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,66 +1,66 @@ gInFullScreen = false; _setFrameSize = function() { - if (gInFullScreen) { - // TODO test it seriously - var headerHeight = $("#header").height(); - var windowHeight = $(window).height(); - var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2 + if (gInFullScreen) { + // TODO test it seriously + var headerHeight = $("#header").height(); + var windowHeight = $(window).height(); + var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2 - var windowWidth = $(window).width(); - var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2 + var windowWidth = $(window).width(); + var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2 - // TODO test if we're embeded ! wont work otherwise anyway (frame security concerns) - $("#text_view_frame").css( { - 'position' :'absolute', - 'left' :'0px', - 'top' :headerHeight, - 'width' :frameWidth, - 'height' :frameHeight - }); - } - else { - // TODO test it seriously - var frameTop = Math.ceil($("#text_view_frame_container").position()["top"]); + // TODO test if we're embeded ! wont work otherwise anyway (frame security concerns) + $("#text_view_frame").css( { + 'position' :'absolute', + 'left' :'0px', + 'top' :headerHeight, + 'width' :frameWidth, + 'height' :frameHeight + }); + } + else { + // TODO test it seriously + var frameTop = Math.ceil($("#text_view_frame_container").position()["top"]); - var windowHeight = $(window).height(); - var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2 - - var windowWidth = $(window).width(); - var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2 + var windowHeight = $(window).height(); + var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2 + + var windowWidth = $(window).width(); + var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2 - // TODO test if we're embeded ! wont work otherwise anyway (frame security) - $("#text_view_frame").css( { - 'position' :'relative', - 'width' :'99.9%', - 'height' :frameHeight, - 'top' :'0px' - }); - } + // TODO test if we're embeded ! wont work otherwise anyway (frame security) + $("#text_view_frame").css( { + 'position' :'relative', + 'width' :'99.9%', + 'height' :frameHeight, + 'top' :'0px' + }); + } } _toFullScreenSize = function() { - gInFullScreen = true; - _setFrameSize() ; + gInFullScreen = true; + _setFrameSize() ; - frames['text_view_frame'].$("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png'); + frames['text_view_frame'].$("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png'); - frames['text_view_frame'].f_setCookie('fullscreen', '1') ; + frames['text_view_frame'].f_setCookie('fullscreen', '1') ; }; _toNormalSize = function() { - gInFullScreen = false; - _setFrameSize() ; + gInFullScreen = false; + _setFrameSize() ; - frames['text_view_frame'].$("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png'); - - frames['text_view_frame'].f_setCookie('fullscreen', '0') ; + frames['text_view_frame'].$("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png'); + + frames['text_view_frame'].f_setCookie('fullscreen', '0') ; }; _toInitialSize = function() { - //console.info('_toInitialSize') ; - var fullscreen = ($.cookie('fullscreen') == '1'); - if (fullscreen) - _toFullScreenSize() ; - else - _toNormalSize() ; + //console.info('_toInitialSize') ; + var fullscreen = ($.cookie('fullscreen') == '1'); + if (fullscreen) + _toFullScreenSize() ; + else + _toNormalSize() ; }; diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/site/text_view_to_frame.js --- a/src/cm/media/js/site/text_view_to_frame.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/site/text_view_to_frame.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,21 +1,21 @@ v_toggleFrameSize = function() { - if (gInFullScreen) - _toNormalSize() ; - else - _toFullScreenSize() ; + if (gInFullScreen) + _toNormalSize() ; + else + _toFullScreenSize() ; } //v_toNormalSize = function() { -// _toNormalSize() ; +// _toNormalSize() ; //} // v_toInitialSize = function() { - _toInitialSize() ; - $(window).resize(function(){ -// console.log('before setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; - _setFrameSize(); -// console.log('after setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; - }); + _toInitialSize() ; + $(window).resize(function(){ +// console.log('before setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; + _setFrameSize(); +// console.log('after setFramesize in top resize winwidth' + frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ; + }); }