UNPKG

zmp-core

Version:

Full featured mobile HTML framework for building iOS & Android apps

65 lines 1.95 kB
import $ from '../../shared/zmp-dom'; import { extend } from '../../shared/utils'; import ListIndex from './list-index-class'; import ConstructorMethods from '../../shared/constructor-methods'; export default { name: 'listIndex', static: { ListIndex: ListIndex }, create: function create() { var app = this; app.listIndex = ConstructorMethods({ defaultSelector: '.list-index', constructor: ListIndex, app: app, domProp: 'zmpListIndex' }); }, on: { tabMounted: function tabMounted(tabEl) { var app = this; $(tabEl).find('.list-index-init').each(function (listIndexEl) { var params = extend($(listIndexEl).dataset(), { el: listIndexEl }); app.listIndex.create(params); }); }, tabBeforeRemove: function tabBeforeRemove(tabEl) { $(tabEl).find('.list-index-init').each(function (listIndexEl) { if (listIndexEl.zmpListIndex) listIndexEl.zmpListIndex.destroy(); }); }, pageInit: function pageInit(page) { var app = this; page.$el.find('.list-index-init').each(function (listIndexEl) { var params = extend($(listIndexEl).dataset(), { el: listIndexEl }); app.listIndex.create(params); }); }, pageBeforeRemove: function pageBeforeRemove(page) { page.$el.find('.list-index-init').each(function (listIndexEl) { if (listIndexEl.zmpListIndex) listIndexEl.zmpListIndex.destroy(); }); } }, vnode: { 'list-index-init': { insert: function insert(vnode) { var app = this; var listIndexEl = vnode.elm; var params = extend($(listIndexEl).dataset(), { el: listIndexEl }); app.listIndex.create(params); }, destroy: function destroy(vnode) { var listIndexEl = vnode.elm; if (listIndexEl.zmpListIndex) listIndexEl.zmpListIndex.destroy(); } } } };