Advertisement
fruffl

cinema bg image

Jul 1st, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cinematic : function(__SELF, SETTINGS)
  2. {
  3.     var regName = 'app-cinematic';
  4.    
  5.     var __settings = jQuery.extend
  6.     (
  7.         true,
  8.         {
  9.             bioscoop : null, // id of target
  10.             autoplay :
  11.             {
  12.                 enabled : false,
  13.                 interval : 10,
  14.                 showNext : true,
  15.                 showPlay : true,
  16.                 showPrev : true,
  17.                 showTimer : true,
  18.             },
  19.             thumbs :
  20.             {
  21.                 preloadAllBeforeShow : true,
  22.                 callBackAfterShow : function() {},
  23.                 asCssBackgroundImage : true // otherwise img-tag
  24.             },
  25.             loader :
  26.             {
  27.                 lines           : 16,
  28.                 length          : 50,
  29.                 width           : 1,
  30.                 radius          : 40,
  31.                 rotate          : 0,
  32.                 color           : '#00FF1A',
  33.                 speed           : 1.9,
  34.                 trail           : 100,
  35.                 shadow          : false,
  36.                 hwaccel         : true,
  37.                 className       : 'ddlsl',
  38.                 zIndex          : -1,//2e9,
  39.                 top             : 0,
  40.                 left            : 'auto'
  41.             }
  42.         },
  43.         SETTINGS
  44.     );
  45.  
  46.     var log =
  47.     {
  48.         n    : function(t, l) { $.tri4m.log('tri4m.app.cinematic: ' + t, l); },
  49.         t    : function(t, l) { log.n('trigger: ' + t, l); },
  50.         t107 : function(t, l) { log.t('preload-cinematic-thumb: ' + t, l); },
  51.         t108 : function(t, l) { log.t('preload-cinematic-image: ' + t, l); },
  52.         t109 : function(t, l) { log.t('-- event: ' + t, l); }
  53.     };
  54.  
  55.     var __instance = function(element)
  56.     {
  57.         var _queue = [], _removed = [], _element = element,
  58.         _isset = $.tri4m.global.__INSTANCE_REGISTRY__.isset(element, regName),
  59.         _init, _dom, _reg = {}, _bnd = {}, _update,
  60.         _ctrl =
  61.         {
  62.             onActivation : function(scrollrollerItem)
  63.             {
  64.                 scrollrollerItem.parent().data('tri4m.ui.scrollroller.listitem.state', {ai : scrollrollerItem});
  65.                 scrollrollerItem.find('a').trigger('tri4m.app.cinematic.reslink.preloadImage');
  66.             }
  67.         };
  68.  
  69.         _c =
  70.         {
  71.             o : function(t)
  72.             {
  73.                 var p = {width: 0, height: 0};
  74.                
  75.                 if(t.innerWidth() > 0)
  76.                 {
  77.                     p.width = t.innerWidth();
  78.                 }
  79.                 else
  80.                 if(t.innerWidth() === 0
  81.                 && t.parent().innerWidth() > 0)
  82.                 {
  83.                     p.width = t.parent().innerWidth();
  84.                 }
  85.                 else
  86.                 {
  87.                     p.width = $(window).width();
  88.                 }
  89.                
  90.                 if(t.innerHeight() > 0)
  91.                 {
  92.                     p.height = t.innerHeight();
  93.                 }
  94.                 else
  95.                 if(t.innerHeight() === 0
  96.                 && t.parent().innerHeight() > 0)
  97.                 {
  98.                     p.height = t.parent().innerHeight();
  99.                 }
  100.                 else
  101.                 {
  102.                     p.height = $(window).height();
  103.                 }
  104.                
  105.                 return p;
  106.             },
  107.             i : function(image, target)
  108.             {
  109.                 var p = {width: 0, height: 0, left: 0, top: 0};
  110.  
  111.                 if(typeof image !== 'object'
  112.                 || typeof image.width === 'undefined'
  113.                 || typeof image.height === 'undefined') return p;
  114.  
  115.                 var iw = image.width, ih = image.height, ir = ih / iw
  116.                     w = _c.o(target), ww = w.width, wh = w.height, wr = wh / ww;
  117.  
  118.                 switch(true)
  119.                 {
  120.                     case (wr > ir):
  121.                         p.width  = Math.round(wh/ir);
  122.                         p.height = wh;
  123.                         break;
  124.                     case (typeof $('body.fit-images').size() !== 'undefined'):
  125.                         p.width  = ww;
  126.                         p.height = wh;
  127.                         break;
  128.                     case (ir > 1 || ir === 1):
  129.                         var j = wh / ih;
  130.                         p.width  = Math.round(iw * j);
  131.                         p.height = wh;
  132.                         break;
  133.                     default:
  134.                         p.width  = ww;
  135.                         p.height = Math.round(ww * ir);
  136.                         break;
  137.                 }
  138.  
  139.                 p.left = Math.round((ww - p.width)  / 2);
  140.                 p.top  = Math.round((wh - p.height) / 2);
  141.  
  142.                 return p;
  143.             }
  144.         };
  145.  
  146.         _j =
  147.         {
  148.             __isw  : false,
  149.             window : function()
  150.             {
  151.                 var d = _reg.j.get('d');
  152.                 var wait = setInterval(function()
  153.                 {
  154.                     clearInterval(wait);
  155.                     _j.__isw = false;
  156.                     d.find('img:visible')
  157.                     .each(function()
  158.                     {
  159.                         $(this).animate(_c.i({width : $(this).width(), height : $(this).height()}, d), 500, 'easeOutCubic');
  160.                     });
  161.                 }, 600);
  162.  
  163.                 if(true === _j.__isw)
  164.                     clearInterval(wait);
  165.  
  166.                 _j.__isw = true;
  167.             }
  168.         }
  169. /*
  170.  
  171. */
  172.         _update = function()
  173.         {
  174.             var j = _reg.j, __i = 'li', __a = 'a',
  175.                 ba = _bnd.a.toValueObject(), bi = _bnd.i.toValueObject(), bt = _bnd.t.toValueObject();
  176.  
  177.             j.register('a', $(__a, j.get('l')), false);
  178.             j.register('i', $(__i, j.get('l')), false);
  179.             j.get('a').addClass('tri4m-app-cinematic-resourcelink').hide();
  180.             j.get('i').addClass('tri4m-app-cinematic-resourceitem');
  181.  
  182.             var a = j.get('a'), i = j.get('i'), _a = '<a />';
  183.  
  184.             i.each(function(index)
  185.             {
  186.                 for(var i in bi) $(this).unbind(i).bind(i, bi[i]);
  187.                 var it = $(this).find(__a + '.tri4m-app-cinematic-resourcethumb').eq(0);
  188.                 if(it.length === 0) $(this).append($(_a).addClass('tri4m-app-cinematic-resourcethumb').hide());
  189.             });
  190.  
  191.             j.register('t', $(__a + '.tri4m-app-cinematic-resourcethumb', j.get('i')), false);
  192.             var t = j.get('t');
  193.  
  194.             a.each(function(index)
  195.             {
  196.                 for(var i in ba) $(this).unbind(i).bind(i, ba[i]);
  197.                 $(this).addClass('j.a');
  198.             });
  199.  
  200.             t.each(function(index)
  201.             {
  202.                 for(var i in bt) $(this).unbind(i).bind(i, bt[i]);
  203.  
  204.                 var ds = $(this).data(_reg.n.get('dts')), dd = {}; dd.i = index;
  205.                
  206.                 if(typeof ds === 'undefined')
  207.                 {
  208.                     $(this).data(_reg.n.get('dts'), dd);
  209.                     ds = dd;
  210.                 }
  211.                
  212.                 if(typeof ds.qs === 'undefined')
  213.                 {
  214.                     $(this).trigger('tri4m.app.cinematic.thumblink.preloadImage');
  215.                 }
  216.                 else
  217.                 {
  218.                     $(this).addClass('status_' + ds.qs.status);
  219.                 }
  220.                
  221.                 $(this).addClass('j.t');
  222.             });
  223.            
  224.             j.get('l').addClass('j.l');
  225.         };
  226.  
  227.         _dom = function()
  228.         {
  229.             var j = _reg.j, _d = '<div />', _l = '<ul />',
  230.                 __d = 'div', __i = 'li', __a = 'a', _a = '<a />', __l = 'ul',
  231.                 d = $('#' + __settings.bioscoop).find(__d).eq(0),
  232.                 l = _element.find(__l).eq(0); // 0: cur is ul
  233.  
  234.             j.register('b', $('#' + __settings.bioscoop), true);
  235.             j.register('d', ((d.length === 0) ? $(_d).appendTo(j.get('b')) : d), true);
  236.             j.register('l', ((l.length === 0) ? $(_element).wrap(_d) : l), true);
  237.             j.register('c', j.get('l').parent());
  238.  
  239.             j.get('l').addClass('tri4m-app-cinematic-list');
  240.             j.get('b').addClass('tri4m-app-cinematic-bioscoop');
  241.             j.get('d').addClass('tri4m-app-cinematic-decorontwerp')
  242.                 .css({overflow: 'hidden'})
  243.                 .data(_reg.n.get('dcs'), { initialized : false });
  244.             j.get('c').addClass('tri4m-ui-scrollroller-x tri4m-app-gallery-thumbs tri4m-app-cinematics')
  245.             //j.get('c').addClass('tri4m-ui-scrollroller-x tri4m-app-cinematics')
  246.                 .tri4m().proto().ui().scrollroller
  247.                 ({
  248.                     sensitive: true,
  249.                     easing :
  250.                     {
  251.                         duration : 400,
  252.                         callback :
  253.                         {
  254.                             item :
  255.                             {
  256.                                 deactivate : function(e)
  257.                                 {
  258.                                     $(this).trigger('tri4m.ui.scrollroller.container.activateFirst');
  259.                                 }
  260.                             }
  261.                         }
  262.                     }
  263.                 });
  264.  
  265.         };
  266.  
  267.         (function()
  268.         {
  269.             if(true === _isset) return;
  270.            
  271.             _reg.j = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  272.             _reg.n = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  273.             _bnd.a = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  274.             _bnd.t = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  275.             _bnd.i = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  276.             _bnd.l = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  277.             _bnd.r = new $.tri4m.global.__CLASS__.__VARIABLE__.__REGISTRY__();
  278.  
  279.             _reg.n.register('dcs', 'tri4m.app.cinematic.state');
  280.             _reg.n.register('dts', 'tri4m.app.cinematic.thumbstate');
  281.  
  282.             _bnd.i
  283.             .register('click', function()
  284.             {
  285.                 log.t109('tri4m.app.cinematic.listitem.click', 1);
  286.                 $(this).trigger('tri4m.ui.scrollroller.listitem.activate', [_ctrl.onActivation]);
  287.             });
  288.            
  289.             _bnd.l
  290.             .register('tri4m.app.cinematic.container.insertItemAfter', function(e, i, c)
  291.             {
  292.                 log.t109('tri4m.app.cinematic.container.insertItemAfter', 1);
  293.             }, true)
  294.             .register('tri4m.app.cinematic.container.insertItemBefore', function(e, i, c)
  295.             {
  296.                 log.t109('tri4m.app.cinematic.container.insertItemBefore', 1);
  297.             }, true)
  298.             .register('tri4m.app.cinematic.container.appendItem', function(e, i, item, c)
  299.             {
  300.                 log.t109('tri4m.app.cinematic.container.appendItem', 1);
  301.                 alert('insert cinematic');
  302.             }, true)
  303.             .register('tri4m.app.cinematic.container.appendItems', function(e, i, itemArray, c)
  304.             {
  305.                 log.t109('tri4m.app.cinematic.container.prependItems', 1);
  306.             }, true)
  307.             .register('tri4m.app.cinematic.container.prependItem', function(e, i, item, c)
  308.             {
  309.                 log.t109('tri4m.app.cinematic.container.prependItems', 1);
  310.             }, true)
  311.             .register('tri4m.app.cinematic.container.prependItems', function(e, i, itemArray, c)
  312.             {
  313.                 log.t109('tri4m.app.cinematic.container.prependItems', 1);
  314.             }, true)
  315.             .register('tri4m.app.cinematic.container.removeItem', function(e, i, c)
  316.             {
  317.                 log.t109('tri4m.app.cinematic.container.removeItem', 1);
  318.                 var t  = $(e.target);
  319.                 t.trigger('click');
  320.                 t.trigger('tri4m.ui.scrollroller.container.removeItem', [i, function()
  321.                 {
  322.                     _ctrl.next(_reg.j.get('l'));
  323.                 }]);
  324.                
  325.             }, true)
  326.             .register('tri4m.app.cinematic.container.pause', function(e, c)
  327.             {
  328.                 log.t109('tri4m.app.cinematic.container.pause', 1);
  329.                
  330.             }, true)
  331.             .register('tri4m.app.cinematic.container.play', function(e, c)
  332.             {
  333.                 log.t109('tri4m.app.cinematic.container.play', 1);
  334.            
  335.             }, true)
  336.             .register('tri4m.app.cinematic.container.stop', function(e, c)
  337.             {
  338.                 log.t109('tri4m.app.cinematic.container.stop', 1);
  339.            
  340.             }, true)
  341.             .register('tri4m.app.cinematic.container.nextItem', function(e, c)
  342.             {
  343.                 log.t109('tri4m.app.cinematic.container.nextItem', 1);
  344.                 _reg.j.get('l').trigger('tri4m.ui.scrollroller.container.activateNextOrFirst', [_ctrl.onActivation]);
  345.             }, true)
  346.             .register('tri4m.app.cinematic.container.prevItem', function(e, c)
  347.             {
  348.                 log.t109('tri4m.app.cinematic.container.prevItem', 1);
  349.                 _reg.j.get('l').trigger('tri4m.ui.scrollroller.container.activatePrevOrLast', [_ctrl.onActivation]);
  350.             }, true);
  351.  
  352.             _bnd.t
  353.             .register('tri4m.app.cinematic.thumblink.preloadImage', function(e)
  354.             {
  355.                 log.t109('tri4m.app.cinematic.thumblink.preloadImage', 1);
  356.                 if(typeof ILLI === 'undefined')
  357.                 {
  358.                     $(this).parent().prepend('<span>where is ILLI?</span>');
  359.                     log.t107('ILLI is undefined (required for thumb-url)', 2);
  360.                     return;
  361.                 }
  362.  
  363.  
  364.                 var t = $(this), p = t.parent().css({opacity : 0}),
  365.                     i = t.data(_reg.n.get('dts')).i, href = $('a.tri4m-app-cinematic-resourcelink', p).attr('href'),
  366.                     ds = t.data(_reg.n.get('dts'));
  367.                
  368.                 if(typeof ds.qs !== 'undefined')
  369.                     return;
  370.  
  371.                 log.t107('init ' + i);
  372.  
  373.                 if(typeof _queue[i] !== 'undefined' && _queue[i].status === true)
  374.                 {
  375.                     log.t107('-- nothing to do ' + i);
  376.                     return;
  377.                 }
  378.  
  379.                 log.t107('push to queue ' + i);
  380.  
  381.                 _queue[i] =
  382.                 {
  383.                     status    : false,
  384.                     error     : false,
  385.                     append    : false,
  386.                     kicked    : false,
  387.                     lookup    : null,
  388.                     islooking : false,
  389.                     attempt   : 0,
  390.                     thumb     : t,
  391.                     parent    : p,
  392.                     src       : null,
  393.                     image     : $('<img />').addClass('tri4m-app-cinematic-thumbnail').css({opacity : 0})
  394.                 };
  395.                
  396.                 ds.qs = _queue[i];
  397.                 t.data(_reg.n.get('dts'), ds);
  398.  
  399.                 var islast = (_queue.length === _reg.j.get('t').length);
  400.                
  401.                 if(true === islast) log.t107('is last ' + i);
  402.  
  403.                 var dequeue = function()
  404.                 {
  405.                     log.t107('try dequeue: caller is ' + i);
  406.                     if(true === __settings.thumbs.preloadAllBeforeShow)
  407.                     {
  408.                         if(false === islast)
  409.                             return;
  410.  
  411.                         log.t107('try dequeue: preloadAllBeforeShow = true');
  412.  
  413.                         var success = true;
  414.                        
  415.                         for(var idx in _queue)
  416.                             if(_queue[idx].status === false)
  417.                                 success = false;
  418.  
  419.                         if(false === success)
  420.                         {
  421.                             log.t107('try dequeue: success = false');
  422.                             var refetch = setInterval(function()
  423.                             {
  424.                                 clearInterval(refetch);
  425.  
  426.                                 log.t107('try again; attempt = ' + _queue[i].attempt );
  427.                                 //dequeue();
  428.                             }, 500);
  429.                             //return;
  430.                         }
  431.                     }
  432.  
  433.                     log.t107('try dequeue: start iteration');
  434.                    
  435.                     for(var idx in _queue)
  436.                     {
  437.                         if(true === _queue[idx].error)
  438.                         {
  439.                             log.t107('try dequeue: error: ' + src, 3);
  440.                             log.t107('try dequeue: --continue');
  441.                             continue;
  442.                         }
  443.  
  444.                         (function(curIndex, caller)
  445.                         {
  446.                             var islast = (_queue.length === _queue[curIndex + 1]);
  447.                            
  448.                             if(null !== _queue[curIndex].lookup)
  449.                                 return;
  450.                            
  451.                             _queue[curIndex].lookup = setInterval(function()
  452.                             {
  453.                                 //log.t107('try dequeue: auto-init ' + x);
  454.                                
  455.                                 if(true === _queue[curIndex].kicked)
  456.                                 {
  457.                                     log.t107('try dequeue: waiting: -- -- index ' + curIndex + ' already kicked');
  458.                                     clearInterval(_queue[curIndex].lookup);
  459.                                     return;
  460.                                 }
  461.                                
  462.                                 //if(false === __settings.thumbs.preloadAllBeforeShow
  463.                                 //&& _queue[curIndex].status === false)
  464.                                 if(_queue[curIndex].status === false)
  465.                                 {
  466.                                     log.t107('try dequeue: waiting: preloadAllBeforeShow = ' + __settings.thumbs.preloadAllBeforeShow + ', status = '+ _queue[curIndex].status +', try = ' + _queue[curIndex].attempt + ' of ' + _queue.length + ', index = ' + curIndex + ', caller = ' + caller);
  467.  
  468.                                     if(_queue[curIndex].attempt > _queue.length || _queue[curIndex].attempt === _queue.length)
  469.                                     {
  470.                                         log.t107('try dequeue: waiting: -- preloadAllBeforeShow =  = ' + __settings.thumbs.preloadAllBeforeShow + ', status = '+ _queue[curIndex].status +', max.attempts = '+_queue.length+', index = ' + curIndex + ', caller = ' + caller);
  471.                                         log.t107('try dequeue: waiting: -- index ' + curIndex + ' was kicked from #list (idle flood), caller = ' + caller + ' in try = ' + _queue[curIndex].attempt + ' of ' + _queue.length, 3);
  472.                                         _queue[curIndex].kicked = true;
  473.                                         _queue[curIndex].error  = true;
  474.                                         clearInterval(_queue[curIndex].lookup);
  475.                                         _removed[curIndex] = _queue[curIndex];
  476.                                         //_queue[curIndex].parent.remove();
  477.                                         //_update();
  478.                                         _reg.j.get('l').trigger('tri4m.app.cinematic.container.removeItem', [curIndex]);
  479.                                     }
  480.                                    
  481.                                     _queue[curIndex].attempt++;
  482.  
  483.                                     return;
  484.                                 }
  485.  
  486.                                 clearInterval(_queue[curIndex].lookup);
  487.                                
  488.                                 if(true === _queue[curIndex].append)
  489.                                     return;
  490.                                
  491.                                 var show = function()
  492.                                 {
  493.                                     if(typeof ILLI === 'undefined'
  494.                                     || false === __settings.thumbs.preloadAllBeforeShow)
  495.                                     {
  496.                                         _queue[curIndex].parent.animate({opacity : 1}, 500);
  497.                                         return;
  498.                                     }
  499.                                    
  500.                                     ILLI.fn.idle(_queue[curIndex].parent, curIndex * 100, function()
  501.                                     {
  502.                                         _queue[curIndex].parent.animate({opacity : 1}, 500);
  503.                                     });
  504.                                 };
  505.  
  506.                                 if(true === __settings.thumbs.asCssBackgroundImage)
  507.                                 {
  508.                                     log.t107('try dequeue: asCssBackgroundImage = true ' + curIndex);
  509.                                     _queue[curIndex].parent.css({'background-image' : 'url("' + _queue[curIndex].src + '")'});
  510.                                     show();
  511.                                 }
  512.                                 else
  513.                                 {
  514.                                     log.t107('try dequeue: asCssBackgroundImage = false ' + curIndex);
  515.                                     _queue[curIndex].parent.prepend(_queue[curIndex].image);
  516.                                     show();
  517.                                 }
  518.                                
  519.                                 _queue[curIndex].append = true;
  520.                                 _queue[curIndex].status = true;
  521.                                
  522.                                 var ds = _queue[curIndex].thumb.data(_reg.n.get('dts'));
  523.                                 ds.qs = _queue[curIndex];
  524.                                 _queue[curIndex].thumb.data(_reg.n.get('dts'), ds);
  525.                                 _queue[curIndex].thumb.addClass('status_' + _queue[curIndex].status);
  526.  
  527.  
  528.                                 //if(islast === true) __settings.thumbs.callBackAfterShow();
  529.  
  530.                             }, 200);
  531.                         })(idx, i);
  532.                     }
  533.                 }
  534.  
  535.                 var load = function(src)
  536.                 {
  537.                     log.t107('try load: ' + src);
  538.                    
  539.                     var IMG = new Image();
  540.                    
  541.                     $(IMG)
  542.                     .addClass('dummy')
  543.                     .hide()
  544.                     .load(function()
  545.                     {
  546.                         log.t107('try load: complete: ' + src);
  547.                        
  548.                         $(IMG).remove();
  549.                        
  550.                         t.wait = setInterval(function()
  551.                         {
  552.                             clearInterval(t.wait);
  553.                             log.t107('try load: append: ' + src);
  554.                             _queue[i].image.attr('src', src);
  555.                             _queue[i].src = src;
  556.                             _queue[i].status = true;
  557.                             dequeue();
  558.  
  559.                         }, 100);
  560.  
  561.                         IMG.onload = function(){};
  562.                     })
  563.                     .error(function()
  564.                     {
  565.                         log.t107('try load: error: ' + src, 3);
  566.                        
  567.                         _queue[i].image.attr('src', src);
  568.                         _queue[i].src = src;
  569.                         _queue[i].status = true;
  570.                         _queue[i].error = true;
  571.                        
  572.                         dequeue();
  573.                        
  574.                         IMG.onerror = function(){};
  575.                     });
  576.  
  577.                     $(IMG).attr('src', src);
  578.                     t.append(IMG);
  579.                 };
  580.  
  581.                 t.idle = setInterval(function()
  582.                 {
  583.                     clearInterval(t.idle);
  584.                     log.t107('try get thumb for ' + i + ': ' + href);
  585.                    
  586.                     // create thumb url from img-a-href                                
  587.                     ILLI.router.create.thumb(href, p.height(), p.width(), function(url)
  588.                     {
  589.                         log.t107('thumb for ' + i + ' is ' + url);
  590.                         t.attr('href', url);
  591.                         load(url);
  592.                     });
  593.                 }, 50);
  594.             });
  595.  
  596.             _bnd.a.register('tri4m.app.cinematic.reslink.preloadImage', function()
  597.             {
  598.                 log.t109('tri4m.app.cinematic.reslink.preloadImage', 1);
  599.                 log.t108('init ' + src);
  600.                
  601.                 var src  = $(this).attr('href');                               
  602.                 var load = function()
  603.                 {
  604.                     log.t108('try load: ' + src);
  605.                    
  606.                     if(_reg.j.get('d').children('img' + "[src='" + src + "']").length === 0)
  607.                     {
  608.                         switch(true)
  609.                         {
  610.                             case src.match(/png/i): log.t108('try load: PNG ' + src); break;
  611.                             case src.match(/jpg/i): log.t108('try load: JPG ' + src); break;
  612.                             case src.match(/gif/i): log.t108('try load: GIF ' + src); break;
  613.                             default: log.t108('try load: unknown source ' + src); break;
  614.                         }  
  615.                        
  616.                         var IMG = new Image(), img = $('<img />')
  617.                             .css({position: 'absolute'})
  618.                             .addClass('tri4m-app-cinematic-image')
  619.                             .css('position', 'absolute');
  620.                            
  621.                         $(IMG).hide()
  622.                         .load(function()
  623.                         {
  624.                             log.t108('try load: complete: ' + src);
  625.                            
  626.                             var css = _c.i(IMG, _reg.j.get('d'));
  627.                            
  628.                             $(IMG).remove();
  629.                            
  630.                             var wait = setInterval(function()
  631.                             {
  632.                                 clearInterval(wait);
  633.                                 log.t108('try load: append: ' + src);
  634.                                 _reg.j.get('d').prepend(img.attr('src', src).css(css));
  635.                                 _reg.j.get('d').animate({opacity : 1}, 500);
  636.                             }, 100);
  637.  
  638.                             IMG.onload = function(){};
  639.                         })
  640.                         .error(function()
  641.                         {
  642.                             log.t108('try load: error: ' + src, 3);
  643.                             IMG.onerror = function(){};
  644.                         });
  645.  
  646.                         $(IMG).attr('src', src);
  647.                         _reg.j.get('d').html(IMG);
  648.  
  649.                     }
  650.                     else
  651.                     {
  652.                         log.t108('try load: known source ' + src);
  653.                        
  654.                         var img = _reg.j.get('d').children('img' + "[src='" + src + "']");
  655.                         img.show();
  656.                         _reg.j.get('d').animate({opacity : 1}, 500);
  657.                     }
  658.                 };
  659.  
  660.                 if(_reg.j.get('d').children('img').length === 0)
  661.                 {
  662.                     log.t108('try load: bioscoop has no images -- construct sequence');
  663.                    
  664.                     _reg.j.get('d').css({opacity : 0});
  665.                     load();
  666.                 }
  667.                 else
  668.                 {
  669.                     log.t108('try load: bioscoop has images -- destruct-construct sequence');
  670.                    
  671.                     _reg.j.get('d').stop().animate({opacity : 0}, 500, function()
  672.                     {
  673.                         $('img', _reg.j.get('d')).remove();
  674.                         load();
  675.                     });
  676.                 }
  677.  
  678.  
  679.             }, true);
  680.  
  681.             _bnd.r.register('resize.resolutionchange', _j.window, true);
  682.            
  683.             var foo = false;
  684.             __settings.thumbs.callBackAfterShow = function()
  685.             {
  686.                 if(true === foo) return;
  687.                 foo = true;
  688.                 _update();
  689.             };
  690.             _dom();
  691.             _update();
  692.  
  693.             var br = _bnd.r.toValueObject(), bl = _bnd.l.toValueObject();
  694.             for(var i in br) { $(window).bind(i, br[i]); }
  695.             for(var i in bl) { _reg.j.get('l').unbind(i).bind(i, bl[i]); }
  696.            
  697.             _reg.j.get('l').trigger('insert-item');
  698.            
  699.             if(__settings.bioscoop === null)
  700.             {
  701.                 __settings.bioscoop = 'target';
  702.                 $('body').prepend('<div id="'+ __settings.bioscoop +'"/>');
  703.             }
  704.             _update();
  705.         })();
  706.     };
  707.  
  708.     $.tri4m.log('initialize tri4m.app.cinematic: tri4m LABS', 1);
  709.     var instance = new __instance(__SELF);
  710.     $.tri4m.global.__INSTANCE_REGISTRY__.register(__SELF, regName, instance);
  711. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement