classify.js
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
define("portal/classify", ['utils','zepto', 'juicer'], function (_u) {
var classify = {
el: "#page-classify",
tmpl: $("#classify-tmpl").html(),
getApps: function() {
return _u.ajax({action: "getAppsByUser"});
},
render: function(res) {
var $el = $(this.el);
var tmpl = juicer(this.tmpl, res);
$el.find(".classifies").html(tmpl);
this.bindEvent();
},
bindEvent: function() {
var $el = $(this.el);
require(["sortable"], function (Sortable) {
var $apps = $el.find(".apps");
$apps.on('click', '.app', function () {
var href = $(this).data('href');
window.open(href, "_self");
});
$apps.each(function () {
Sortable.create(this, {
delay: 300,
handle: '.app',
animation: 150,
forceFallback: true,
supportPointer: false,
scroll: false,
chosenClass: "app-chosen",
ghostClass: "app-ghost",
dragClass: "app-drag",
onEnd: function(e) {
var $apps = $(e.target), appids = [];
if (e.newIndex === e.oldIndex) return;
$apps.find(".app").each(function(index, app) {
appids.push($(app).data("appid"));
});
_u.ajax({
action: "sort",
data: { appids: appids.join(",") },
type: "post"
});
}
});
});
});
}
};
return {
init: function () {
var platform_parameters = "";
var portalUrl = window.location.href.split("#")[0];
if(portalUrl.indexOf("?") > -1){//打开移动建模应用时,若缺失移动平台拼接的系统平台参数,会导致一些原生组件功能不能正常使用
platform_parameters = "&" + portalUrl.split("?")[1];
}
classify.tmpl = classify.tmpl.replace("&platform_parameters",platform_parameters);
classify.getApps().then(classify.render.bind(classify));
}
};
});