Показать сообщение отдельно
  #297 (permalink)  
Старый 17.10.2013, 14:23
что-то знаю
Отправить личное сообщение для devote Посмотреть профиль Найти все сообщения от devote
 
Регистрация: 24.05.2009
Сообщений: 5,176

а в чем сложность писать код таким образом?:
//************************************************************************************** Collection
/** @constructor  */
function Collection(widgets, module) {

  if (widgets instanceof Collection) return widgets;

  if (!widgets) {
    this.emptyCollection = true;
    return
  }

  arrayItemsToObject(widgets, this);

  this.template = this.eq(0).clone();
  this.module = module;

}

Collection.prototype = {
    constructor: Collection,
    each: function(callback) {
    },
    add: function(widget) {
    },
    hasElement: function(element) {
    },
    eq: function(index) {
    },
    eqElement: function(index) {
    },
    indexOfElement: function(element) {
    },
    toggle: function(propName) {
    },
    turnOn: function(prop, filter) {
    },
    clickIndex: function(propName) {
    },
    splice: function(index, count, dataArray) {
    },
    insert: function(index, dataArray, toProp) {
    },
    prepend: function(toProp, dataArray) {
    },
    append: function(toProp, dataArray) {
    },
    filter: function(filter) {
    },
    empty: function() {
    },
    remove: function(index) {
    },
    repeat: function(dataArrayProp, toProp) {
    },
    watch: function(prop, callback) {
    },
    model: function(model, b) {
    },
    bind: function(prop) {
    },
    css: function(props, value) {
    },
    width: function(value) {
    },
    on: (function() {
    }
};
и читать код проще, видя всю структуру класса, да и писать тоже куда проще создать новое свойство, чем каждый раз писать Collection.prototype.и_т_д=что_то
__________________
хм Russians say завтра but завтра doesn't mean "tomorrow" it just means "not today."
HTML5 history API рассширение для браузеров не поддерживающих pushState, replaceState
QSA CSS3 Selector Engine
Ответить с цитированием