Browse Source

update

master
zsmj1994 5 years ago
parent
commit
468d8cc74f
  1. 19
      config.js
  2. 75
      item/masonry.block.js
  3. 21
      item/masonry.block.model.js
  4. 37
      masonry.js
  5. 83
      masonry.model.js

19
config.js

@ -0,0 +1,19 @@
!(function () {
BI.config("dec.provider.layout", function (provider) {
provider.inject({
layoutConfig: {
center: {
left: {
width: 550,
maxSize: 800
}
}
}
});
});
BI.config("dec.frame.classic.aside.entry_tree", function (options) {
options.type = "dec.masonry";
return options;
});
}());

75
item/masonry.block.js

@ -0,0 +1,75 @@
!(function () {
var Body = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-frame-body"
},
_store: function () {
return BI.Models.getModel("dec.model.masonry.block", this.options);
},
watch: {
masonry_selectedEntry: function (id) {
this.list.setValue(id);
}
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [
{
el: BI.extend({
type: "dec.common.img.icon_text_item",
height: 36,
logic: {
dynamic: true
},
text: o.text,
imgSrc: o.imgSrc,
iconCls: o.iconCls
})
}, {
el: {
type: "bi.button_group",
ref: function (_ref) {
self.list = _ref;
},
layouts: [
{
type: "bi.vertical"
}
],
items: BI.map(o.items, function (index, item) {
return BI.extend({
type: "dec.common.img.icon_text_item",
height: 30,
cls: "dec-frame-platform-list-item-active dec-font-size-14"
}, item);
}),
listeners: [
{
eventName: "EVENT_CHANGE",
action: function (v) {
self.store.handleItemSelect(v);
}
}
]
},
lgap: 15
}
]
};
},
setValue: function (v) {
this.list.setValue(v);
}
});
BI.shortcut("dec.masonry.block", Body);
}());

21
item/masonry.block.model.js

@ -0,0 +1,21 @@
(function () {
var Store = BI.inherit(Fix.Model, {
state: function () {
return {};
},
context: ["masonry_selectedEntry"],
actions: {
handleItemSelect: function (v) {
this.model.masonry_selectedEntry = v;
var entry = BI.find(this.options.items, function (index, item) {
return item.id === v;
});
BI.Services.getService("dec.service.frame.tab_pane").addItem(entry);
}
}
});
BI.model("dec.model.masonry.block", Store);
}());

37
masonry.js

@ -0,0 +1,37 @@
!(function () {
var Body = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-frame-body"
},
_store: function () {
return BI.Models.getModel("dec.model.masonry");
},
watch: {},
beforeInit: function (cb) {
this.store.initEntryList(cb);
},
render: function () {
var self = this;
return {
type: "bi.button_group",
layouts: [
{
type: "bi.absolute"
}
],
chooseType: BI.Selection.Single,
scrolly: true,
items: this.store.formatItems()
};
}
});
BI.shortcut("dec.masonry", Body);
}());

83
masonry.model.js

@ -0,0 +1,83 @@
(function () {
var Store = BI.inherit(Fix.Model, {
state: function () {
return {
entries: [],
flattenEntry: [],
masonry_selectedEntry: ""
};
},
childContext: ["masonry_selectedEntry"],
actions: {
initEntryList: function (callback) {
var self = this;
Dec.Utils.getCompleteDirectoryTree(function (res) {
self.model.entries = BI.Services.getService("dec.service.frame.entry").normalizeEntries(res.data);
self.groupEntries(false);
callback();
});
},
groupEntries: function () {
var self = this;
var tree = BI.Tree.transformToTreeFormat(this.model.entries);
tree = tree[0];
BI.each(tree.children, function (index, item) {
item.children = self._flattenEntry(item);
});
this.model.flattenEntry = tree.children;
},
formatItems: function () {
var items = [];
var columns = [0, 0];
var flattenEntry = this.model.flattenEntry.slice(0);
flattenEntry = BI.filter(flattenEntry, function (index, entry) {
return BI.isNotEmptyArray(entry.children);
});
var entry = {};
while (flattenEntry.length > 0) {
entry = flattenEntry.shift();
if (columns[0] > columns[1]) {
items.push({
el: BI.extend({
type: "dec.masonry.block",
text: entry.text,
items: entry.children
}, entry),
left: "50%", right: 0,
top: columns[1]
});
columns[1] += (entry.children.length * 30 + 36);
} else {
items.push({
el: BI.extend({
type: "dec.masonry.block",
text: entry.text,
items: entry.children
}, entry),
left: 0, right: "50%",
top: columns[0]
});
columns[0] += (entry.children.length * 30 + 36);
}
}
return items;
}
},
_flattenEntry: function (node) {
var items = [];
BI.Tree.traversal(node.children, function (index, n) {
if (n.entryType !== DecCst.Entries.Entry_Type.FOLDER) {
items.push(n);
}
});
return items;
}
});
BI.model("dec.model.masonry", Store);
}());
Loading…
Cancel
Save