UNPKG

dl

Version:

DreamLab Libs

136 lines (116 loc) 3.8 kB
var Class = require("core").Class; var CdfContainer = require('./CdfContainer.js').CdfContainer, CdfBlock = require("./CdfBlock.js").CdfBlock; /** * @class CdfBlocks */ var CdfBlocks = function () { this.Extends = CdfContainer; /** * @ignore */ this.initialize = function () { this.parent(); }; //FIXME: po co to tutaj jest? this.add = function (model) { this.parent(model); }; this.remove = function (model) { //this. }; this.hasAjaxModels = function () { for (var i = 0, max = this._models.length; i < max; i++){ if (this._models[i].isAjaxRenderable()) { return true; } } return false; } /** * Określa czy isteją modele do zrenderowania * @returns {Boolean} */ this.hasRenderableModels = function () { for (var i = 0, max = this._models.length; i < max; i++){ if (this._models[i].isRendered() == false) { return true; } } return false; }; this.hasNonCacheableModels = function () { for (var i = 0, max = this._models.length; i < max; i++){ if (this._models[i].isCacheable() == false){ return true; } } return false; }; this.hasCacheableModels = function () { for (var i = 0, max = this._models.length; i < max; i++) { if (this._models[i].isCacheable()) { return true; } } return false; }; /** * Zwraca modele mozliwe do umieszczenia w pamieci podrecznej (cache) * @returns {Array} */ this.getCacheableModels = function () { var models = []; for (var i = 0,max = this._models.length; i < max; i++) { this._models[i].isCacheable() && models.push(this._models[i]); } return models; }; /** * @returns {Array} */ this.getNonCacheableModels = function () { var models = []; for (var i = 0, max = this._models.length; i < max; i++) { !this._models[i].isCacheable() && models.push(this._models[i]); } return models; }; /** * Zwraca modele nadające sie do zrenderowania * @returns {Array} */ this.getRenderableModels = function () { var models = []; for (var i = 0, max = this._models.length; i < max; i++) { !this._models[i].isRendered() && models.push(this._models[i]); } return models; }; this.hasTarget = function (name) { for (var i = 0, max = this._models.length; i < max; i++) { if (this._models[i].name == name) { return true; } } return false; }; this.getSmallestCacheTime = function () { // jezeli nie ma blokow to najmniejszy czas cachowania to MIN if (this._models.length == 0) { return CdfBlock.Cache.Value.MIN; } // jezeli sa bloki to szukam najmniejszego czasu cachowania blokow var smallestCacheTime = CdfBlock.Cache.Value.MAX; var tmpCacheTime = null; for (var i = 0, max = this._models.length; i < max; i++) { tmpCacheTime = this._models[i].getCacheTime(); if (tmpCacheTime<smallestCacheTime && tmpCacheTime > 0) { smallestCacheTime = tmpCacheTime; } } return smallestCacheTime; }; }; CdfBlocks = new Class(new CdfBlocks()); exports.CdfBlocks = CdfBlocks;