Skip to content

Commit a10f06e

Browse files
committed
[refactor] improve link module
1 parent b7496ec commit a10f06e

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

‎src/js/link.js‎

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
varlink=(function(){
22

3+
varmod={};
4+
5+
mod.accent={
6+
clear: function(){
7+
bookmarks.get().forEach(function(arrayItem,index){
8+
arrayItem.accent={
9+
override: false,
10+
color: {
11+
r: null,
12+
g: null,
13+
b: null
14+
}
15+
};
16+
});
17+
},
18+
rainbow: function(){
19+
varunits=360/bookmarks.get().length;
20+
vardegree=0;
21+
bookmarks.get().forEach(function(arrayItem,index){
22+
arrayItem.accent.override=true;
23+
arrayItem.accent.color=helper.hslToRgb({
24+
h: degree,
25+
s: 1,
26+
l: 0.5
27+
});
28+
degree=degree+units;
29+
});
30+
}
31+
};
32+
33+
mod.edit=function(){
34+
if(bookmarks.get().length<=0){
35+
helper.setObject({
36+
object: state.get(),
37+
path: "link.edit",
38+
newValue: false
39+
});
40+
};
41+
};
42+
343
varbind={};
444

545
bind.sort=function(){
@@ -653,44 +693,8 @@ var link = (function(){
653693
helper.e(".link-form-text-icon").focus();
654694
};
655695

656-
varmod={};
657-
658-
mod.accent={
659-
clear: function(){
660-
bookmarks.get().forEach(function(arrayItem,index){
661-
arrayItem.accent={
662-
override: false,
663-
color: {
664-
r: null,
665-
g: null,
666-
b: null
667-
}
668-
};
669-
});
670-
},
671-
rainbow: function(){
672-
varunits=360/bookmarks.get().length;
673-
vardegree=0;
674-
bookmarks.get().forEach(function(arrayItem,index){
675-
arrayItem.accent.override=true;
676-
arrayItem.accent.color=helper.hslToRgb({
677-
h: degree,
678-
s: 1,
679-
l: 0.5
680-
});
681-
degree=degree+units;
682-
});
683-
}
684-
};
685-
686-
mod.edit=function(){
687-
if(bookmarks.get().length<=0){
688-
helper.setObject({
689-
object: state.get(),
690-
path: "link.edit",
691-
newValue: false
692-
});
693-
};
696+
varadd=function(){
697+
link.render.add();
694698
};
695699

696700
varinit=function(){
@@ -707,7 +711,8 @@ var link = (function(){
707711
return{
708712
init: init,
709713
mod: mod,
710-
render: render
714+
render: render,
715+
add: add
711716
};
712717

713718
})();

0 commit comments

Comments
(0)