js/index.js
// deserialize model in-place from json

deserialize model in-place from json
deserialize model in - place from json
function initModel(m) {
    if (!m.slots) {
      m.slots = {};
    }
    m.items.forEach(function (item, idx) {
      item.x = item.x || 0;
      item.y = item.y || 0;
      item.index = item.index || idx;
      item.image = item.image || new Image();
      item.image.src = item.src;
      item.slot = item.slot || 0;
      item.attached = false;
      item.home = item.home || {};
      if ( !m.slots[item.slot] ){
        m.slots[item.slot] = {x:0,y:0};
      }
      if (item.x == m.slots[item.slot].x && item.y == m.slots[item.slot].y){
        item.attached = true;
        m.slots[item.slot].item = item;
      }
    });
    _.each(m.slots,function(slot){
      slot.x = slot.x || 0;
      slot.y = slot.y || 0;
    });
    m.background.image = m.background.image || new Image();
    m.background.image.src = m.background.src || '';
    m.canv = document.getElementById("bg");
    m.ctx = m.canv.getContext("2d");
    m.rescale = m.rescale === false ? false : true;
    m.resort = m.resort === false ? false : true;
    m.snap = m.snap || 0;
    m.quantize = typeof m.quantize == "undefined" ? false : m.quantize;
    m.editorOpen = m.editorOpen || false;
    m.imageSmoothing = typeof m.imageSmoothing == "undefined"? true : m.imageSmoothing;
  }
function initModel ( m ) { if ( ! m . slots ) { m . slots = { } ; } m . items . forEach ( function ( item , idx ) { item . x = item . x || 0 ; item . y = item . y || 0 ; item . index = item . index || idx ; item . image = item . image || new Image ( ) ; item . image . src = item . src ; item . slot = item . slot || 0 ; item . attached = false ; item . home = item . home || { } ; if ( ! m . slots [ item . slot ] ) { m . slots [ item . slot ] = { x : 0 , y : 0 } ; } if ( item . x == m . slots [ item . slot ] . x && item . y == m . slots [ item . slot ] . y ) { item . attached = true ; m . slots [ item . slot ] . item = item ; } } ) ; _ . each ( m . slots , function ( slot ) { slot . x = slot . x || 0 ; slot . y = slot . y || 0 ; } ) ; m . background . image = m . background . image || new Image ( ) ; m . background . image . src = m . background . src || '' ; m . canv = document . getElementById ( "bg" ) ; m . ctx = m . canv . getContext ( "2d" ) ; m . rescale = m . rescale === false ? false : true ; m . resort = m . resort === false ? false : true ; m . snap = m . snap || 0 ; m . quantize = typeof m . quantize == "undefined" ? false : m . quantize ; m . editorOpen = m . editorOpen || false ; m . imageSmoothing = typeof m . imageSmoothing == "undefined" ? true : m . imageSmoothing ; }
deserialize model in-place from json
deserialize model in - place from json
// find out if items are attached
