SHOW:
|
|
- or go back to the newest paste.
| 1 | cinematic : function(__SELF, SETTINGS) | |
| 2 | {
| |
| 3 | var regName = 'app-cinematic'; | |
| 4 | ||
| 5 | - | /* |
| 5 | + | |
| 6 | - | based on .w_10 |
| 6 | + | |
| 7 | - | */ |
| 7 | + | |
| 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 | - | preloadAllBeforeShow : false, |
| 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 | - | n : function(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 | - | $.tri4m.log('tri4m.app.cinematic: ' + t, l);
|
| 53 | + | |
| 54 | ||
| 55 | - | t : function(t, l) |
| 55 | + | |
| 56 | {
| |
| 57 | - | log.n('trigger: ' + t, l);
|
| 57 | + | var _queue = [], _removed = [], _element = element, |
| 58 | _isset = $.tri4m.global.__INSTANCE_REGISTRY__.isset(element, regName), | |
| 59 | - | t107 : function(t, l) |
| 59 | + | |
| 60 | _ctrl = | |
| 61 | - | log.t('preload-cinematic-thumb: ' + t, l);
|
| 61 | + | |
| 62 | onActivation : function(scrollrollerItem) | |
| 63 | - | t108 : function(t, l) |
| 63 | + | |
| 64 | scrollrollerItem.parent().data('tri4m.ui.scrollroller.listitem.state', {ai : scrollrollerItem});
| |
| 65 | - | log.t('preload-cinematic-image: ' + t, l);
|
| 65 | + | |
| 66 | } | |
| 67 | }; | |
| 68 | ||
| 69 | _c = | |
| 70 | {
| |
| 71 | - | var _queue = [], |
| 71 | + | |
| 72 | - | _element = element, |
| 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 | - | pause : function() |
| 82 | + | |
| 83 | p.width = t.parent().innerWidth(); | |
| 84 | } | |
| 85 | - | play : function() |
| 85 | + | |
| 86 | {
| |
| 87 | p.width = $(window).width(); | |
| 88 | - | next : function(scrollroller) |
| 88 | + | |
| 89 | ||
| 90 | - | scrollroller.trigger('tri4m.ui.scrollroller.container.activateNextOrFirst', [_ctrl.onActivation]);
|
| 90 | + | |
| 91 | {
| |
| 92 | - | prev : function(scrollroller) |
| 92 | + | |
| 93 | } | |
| 94 | - | scrollroller.trigger('tri4m.ui.scrollroller.container.activateNextOrFirst', [_ctrl.onActivation]);
|
| 94 | + | |
| 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 | - | if(t.innerWidth() === 0 && t.parent().innerWidth() > 0) |
| 109 | + | |
| 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 | - | if(t.innerHeight() === 0 && t.parent().innerHeight() > 0) |
| 124 | + | |
| 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 | - | //p.width = (typeof t === 'undefined' || t.innerWidth() === 0) ? $(window).width() : t.innerWidth(); |
| 133 | + | |
| 134 | - | //p.height = (typeof t === 'undefined' || t.innerHeight() === 0) ? $(window).height() : t.innerHeight(); |
| 134 | + | |
| 135 | p.height = Math.round(ww * ir); | |
| 136 | break; | |
| 137 | } | |
| 138 | ||
| 139 | - | //alert(target.attr('class'));
|
| 139 | + | |
| 140 | p.top = Math.round((wh - p.height) / 2); | |
| 141 | ||
| 142 | return p; | |
| 143 | } | |
| 144 | }; | |
| 145 | ||
| 146 | - | var iw = image.width; |
| 146 | + | |
| 147 | - | var ih = image.height; |
| 147 | + | |
| 148 | - | var ir = ih / iw; |
| 148 | + | __isw : false, |
| 149 | window : function() | |
| 150 | - | var w = _c.o(target); |
| 150 | + | |
| 151 | - | var ww = w.width; |
| 151 | + | |
| 152 | - | var wh = w.height; |
| 152 | + | |
| 153 | - | var wr = wh / ww; |
| 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 | - | isw : false, |
| 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 | - | _j.isw = false; |
| 192 | + | |
| 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 | - | if(true === _j.isw) |
| 200 | + | |
| 201 | {
| |
| 202 | for(var i in bt) $(this).unbind(i).bind(i, bt[i]); | |
| 203 | - | _j.isw = true; |
| 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 | - | if(it.length === 0) |
| 225 | + | |
| 226 | - | $(this).append($(_a).addClass('tri4m-app-cinematic-resourcethumb').hide());
|
| 226 | + | |
| 227 | _dom = function() | |
| 228 | - | $(this).addClass('j.i');
|
| 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 | - | var ds = $(this).data(_reg.n.get('dts'));
|
| 246 | + | |
| 247 | - | var dv = { i : index };
|
| 247 | + | |
| 248 | - | if(!ds) |
| 248 | + | |
| 249 | easing : | |
| 250 | - | dv.created = false; |
| 250 | + | |
| 251 | - | $(this).data(_reg.n.get('dts'), dv).trigger('tri4m.app.cinematic.thumblink.preloadImage');
|
| 251 | + | |
| 252 | callback : | |
| 253 | {
| |
| 254 | item : | |
| 255 | - | $(this).data(_reg.n.get('dts'), dv);
|
| 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 | - | var j = _reg.j, _d = '<div />', _l = '<ul />', __d = 'div', __i = 'li', __a = 'a', _a = '<a />', __l = 'ul'; |
| 268 | + | |
| 269 | - | var d = $('#' + __settings.bioscoop).find(__d).eq(0);
|
| 269 | + | |
| 270 | - | var l = _element.find(__l).eq(0); // 0: cur is ul |
| 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 | - | _bnd.i.register('click', function()
|
| 320 | + | t.trigger('tri4m.ui.scrollroller.container.removeItem', [i, function()
|
| 321 | {
| |
| 322 | _ctrl.next(_reg.j.get('l'));
| |
| 323 | }]); | |
| 324 | ||
| 325 | - | _bnd.l.register('tri4m.app.cinematic.container.insertItemAfter', function(e, i, c)
|
| 325 | + | |
| 326 | .register('tri4m.app.cinematic.container.pause', function(e, c)
| |
| 327 | {
| |
| 328 | - | .register('tri4m.app.cinematic.insertItemBefore', function(e, i, c)
|
| 328 | + | log.t109('tri4m.app.cinematic.container.pause', 1);
|
| 329 | ||
| 330 | }, true) | |
| 331 | - | .register('tri4m.app.cinematic.appendItem', function(e, i, item, c)
|
| 331 | + | .register('tri4m.app.cinematic.container.play', function(e, c)
|
| 332 | {
| |
| 333 | log.t109('tri4m.app.cinematic.container.play', 1);
| |
| 334 | ||
| 335 | - | .register('tri4m.app.cinematic.appendItems', function(e, i, itemArray, c)
|
| 335 | + | |
| 336 | .register('tri4m.app.cinematic.container.stop', function(e, c)
| |
| 337 | {
| |
| 338 | - | .register('tri4m.app.cinematic.prependItem', function(e, i, item, c)
|
| 338 | + | log.t109('tri4m.app.cinematic.container.stop', 1);
|
| 339 | ||
| 340 | }, true) | |
| 341 | - | .register('tri4m.app.cinematic.prependItems', function(e, i, itemArray, c)
|
| 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 | - | _bnd.t.register('tri4m.app.cinematic.thumblink.preloadImage', function(e)
|
| 345 | + | |
| 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 | - | i = t.data(_reg.n.get('dts')).i, href = $('a.tri4m-app-cinematic-resourcelink', p).attr('href');
|
| 356 | + | |
| 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 | - | log.t107('try again');
|
| 409 | + | |
| 410 | - | dequeue(); |
| 410 | + | |
| 411 | - | }, 50); |
| 411 | + | |
| 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 | - | if(false === __settings.thumbs.preloadAllBeforeShow |
| 445 | + | |
| 446 | - | && _queue[curIndex].status === false) |
| 446 | + | |
| 447 | ||
| 448 | - | log.t107('try dequeue: waiting: preloadAllBeforeShow = false, status = '+ _queue[curIndex].status +', try = ' + _queue[curIndex].attempt + ' of ' + _queue.length + ', index = ' + curIndex + ', caller = ' + caller);
|
| 448 | + | |
| 449 | return; | |
| 450 | ||
| 451 | _queue[curIndex].lookup = setInterval(function() | |
| 452 | - | log.t107('try dequeue: waiting: -- preloadAllBeforeShow = false, status = '+ _queue[curIndex].status +', max.attempts = '+_queue.length+', index = ' + curIndex + ', caller = ' + caller);
|
| 452 | + | |
| 453 | - | log.t107('try dequeue: waiting: -- index ' + curIndex + ' was kicked from #list (idle flood), caller = ' + caller + ' in try = ' + _queue[curIndex].attempt + ' of ' + _queue.length);
|
| 453 | + | |
| 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 | - | _queue[curIndex].parent.animate({opacity : 1}, 500);
|
| 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 | - | _queue[curIndex].image.animate({opacity : 1}, 500);
|
| 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 | - | }, curIndex * 500); // every thumber will check every 500ms the full thumb queue! |
| 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 | - | // create thumb url from img-a-href |
| 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 | - | var src = $(this).attr('href');
|
| 547 | + | |
| 548 | $(IMG).remove(); | |
| 549 | - | /* |
| 549 | + | |
| 550 | - | if(_reg.j.get('d').children('div.hidden').length === 0)
|
| 550 | + | |
| 551 | {
| |
| 552 | - | var hidden = $('<div />').hide().addClass('hidden');
|
| 552 | + | |
| 553 | - | _reg.j.get('d').prepend(hidden);
|
| 553 | + | |
| 554 | _queue[i].image.attr('src', src);
| |
| 555 | - | */ |
| 555 | + | |
| 556 | _queue[i].status = true; | |
| 557 | dequeue(); | |
| 558 | ||
| 559 | }, 100); | |
| 560 | ||
| 561 | - | log.t108('try load: unknown source ' + src);
|
| 561 | + | |
| 562 | - | var img = $('<img />').css({position: 'absolute'}).addClass('tri4m-app-cinematic-image').css('position', 'absolute');
|
| 562 | + | |
| 563 | .error(function() | |
| 564 | - | var IMG = new Image(); |
| 564 | + | |
| 565 | - | $(IMG) |
| 565 | + | |
| 566 | - | .hide() |
| 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 | - | log.t108('try load: bioscoop has no images -- construct squence');
|
| 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 | - | log.t108('try load: bioscoop has images -- destruct-construct squence');
|
| 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 | } |