src/cm/media/js/client/c_layout.js
author gibus
Wed, 11 Sep 2013 23:13:01 +0200
changeset 532 0bad3613f59d
parent 525 89ef5ed3c48b
child 562 92e8e5aaacde
permissions -rw-r--r--
Reverse to YUI 3.0.0 since with YUI.3.10.3, comment content including words 'paragraph' or 'section' do not show up on Firefox, this is weird and has to be investigated.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
// globals used: gConf, gPrefs
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
Layout = function() {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
Layout.prototype = {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
     7
  init : function () {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
     8
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
     9
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    10
  isInFrame : function () {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    11
    return (!CY.Lang.isUndefined(parent) && parent.location != location && CY.Lang.isFunction(parent.f_getFrameFilterData)); ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    12
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    13
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    14
  isInComentSite : function () {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    15
    var ret = false;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    16
    try { 
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    17
      if (!CY.Lang.isUndefined(sv_site_url) && !CY.Lang.isUndefined(parent) && !CY.Lang.isUndefined(parent.parent)) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    18
        var parentParentLocation = new String(parent.parent.location) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    19
        // TODO warn server
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    20
        //CY.log(parentParentLocation) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    21
        ret = (parentParentLocation.indexOf(sv_site_url) == 0);
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    22
      }
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    23
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    24
    catch (e) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    25
      ret=false;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    26
      //CY.log("error thrown while trying to access parent.parent.location") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    27
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    28
    //CY.log("inComentSite returned : " + ret) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    29
    return ret ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    30
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    31
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    32
  sliderValToPx : function (val) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    33
    var winWidth = CY.DOM.winWidth() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    34
    if (this.isInFrame()) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    35
       winWidth = parent.$(parent).width() ;    
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    36
    var theta = val / 100 ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    37
    theta = Math.min(theta, gConf['sliderFixedMin']) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    38
    theta = Math.max(theta, gConf['sliderFixedMax']) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    39
    var colWidth = theta * winWidth ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    40
    return Math.floor(colWidth) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    41
  },
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    42
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    43
  getTopICommentsWidth : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    44
    return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get('layout','comments_col_width'))) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    45
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    46
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    47
  getTopICommentsWidthFromWidth : function(val) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    48
    var ret = val - ( 2 * gConf['iCommentThreadPadding']) ; // PhA said : a threaded discussion with a depth of 2 still shoudn't hide the text 20100317
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    49
    return ret - 7;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    50
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    51
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    52
  setLeftColumnWidth : function (colWidth) {
532
0bad3613f59d Reverse to YUI 3.0.0 since with YUI.3.10.3, comment content including words 'paragraph' or 'section' do not show up on Firefox, this is weird and has to be investigated.
gibus
parents: 525
diff changeset
    53
    CY.get('#contentcolumn').setStyle('marginLeft', colWidth + 'px');
0bad3613f59d Reverse to YUI 3.0.0 since with YUI.3.10.3, comment content including words 'paragraph' or 'section' do not show up on Firefox, this is weird and has to be investigated.
gibus
parents: 525
diff changeset
    54
    CY.get('#leftcolumn').setStyle('width', colWidth + 'px');
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    55
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    56
  parentInterfaceUnfreeze : function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    57
    if (this.isInFrame())
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    58
      parent.f_interfaceUnfreeze() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    59
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 217
diff changeset
    60
  
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    61
}