Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.core
Commits
669c7a5e
Commit
669c7a5e
authored
Aug 28, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rendering process documentation.
parent
83a20411
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
vifib/js/render.js
vifib/js/render.js
+24
-1
No files found.
vifib/js/render.js
View file @
669c7a5e
(
function
(
window
,
$
)
{
(
function
(
window
,
$
)
{
'
use strict
'
;
'
use strict
'
;
var
callbacks
=
[];
var
callbacks
=
[];
/* * * * *
* function render:
* this function is the core of rendering process.
*
* param:
* context = the context in which it will show panels
* panels = list of panels (object) to display
* header = topbar of the page
*
* * * * */
$
.
vifib
.
render
=
function
(
context
,
panels
,
header
)
{
$
.
vifib
.
render
=
function
(
context
,
panels
,
header
)
{
var
page
,
i
,
c
;
var
page
,
i
,
c
;
// If the context is body element, it means that we want to show a entire new page
if
(
$
(
'
body
'
)[
0
]
===
$
(
context
)[
0
])
{
if
(
$
(
'
body
'
)[
0
]
===
$
(
context
)[
0
])
{
// First this function check the window mode (mobile, tablet, desktop)
// then define how many panels could be displayed.
if
(
$
.
vifib
.
device
===
'
desktop
'
&&
panels
.
length
>
1
)
{
if
(
$
.
vifib
.
device
===
'
desktop
'
&&
panels
.
length
>
1
)
{
page
=
$
.
vifib
.
multipanel
(
panels
,
3
);
page
=
$
.
vifib
.
multipanel
(
panels
,
3
);
}
else
if
(
$
.
vifib
.
device
===
'
tablet
'
&&
panels
.
length
>
1
)
{
}
else
if
(
$
.
vifib
.
device
===
'
tablet
'
&&
panels
.
length
>
1
)
{
...
@@ -11,6 +24,7 @@
...
@@ -11,6 +24,7 @@
}
else
{
// Mobile
}
else
{
// Mobile
page
=
$
.
vifib
.
onepanel
(
context
,
panels
[
0
]);
page
=
$
.
vifib
.
onepanel
(
context
,
panels
[
0
]);
}
}
// create and add header to the page
if
(
header
!==
undefined
)
{
if
(
header
!==
undefined
)
{
if
(
header
.
hasOwnProperty
(
'
template
'
))
{
if
(
header
.
hasOwnProperty
(
'
template
'
))
{
header
.
data
=
header
.
data
===
undefined
?
undefined
:
header
.
data
;
header
.
data
=
header
.
data
===
undefined
?
undefined
:
header
.
data
;
...
@@ -19,12 +33,14 @@
...
@@ -19,12 +33,14 @@
page
.
prepend
(
Mustache
.
render
(
$
.
vifib
.
header
.
main
,
header
));
page
.
prepend
(
Mustache
.
render
(
$
.
vifib
.
header
.
main
,
header
));
}
}
}
}
// in case of mobile view or if there is only one panel to show, change page with transition
if
(
panels
[
0
].
template
!==
$
.
vifib
.
panel
.
blank
||
(
panels
[
0
].
template
===
$
.
vifib
.
panel
.
blank
&&
$
.
vifib
.
device
!==
'
mobile
'
))
{
if
(
panels
[
0
].
template
!==
$
.
vifib
.
panel
.
blank
||
(
panels
[
0
].
template
===
$
.
vifib
.
panel
.
blank
&&
$
.
vifib
.
device
!==
'
mobile
'
))
{
$
.
vifib
.
changepage
(
$
(
page
));
$
.
vifib
.
changepage
(
$
(
page
));
}
}
}
else
{
}
else
{
// if the context is a panel just refresh it
$
.
vifib
.
replacepanel
(
$
(
context
),
panels
[
0
]);
$
.
vifib
.
replacepanel
(
$
(
context
),
panels
[
0
]);
}
}
// Finally after show page call functions for each panel (callbacks)
// reverse to call functions from left panel to right panel
// reverse to call functions from left panel to right panel
callbacks
.
reverse
();
callbacks
.
reverse
();
while
((
c
=
callbacks
.
pop
())
!==
undefined
)
{
while
((
c
=
callbacks
.
pop
())
!==
undefined
)
{
...
@@ -32,6 +48,7 @@
...
@@ -32,6 +48,7 @@
}
}
};
};
// create one panel (no jqm grid)
$
.
vifib
.
onepanel
=
function
(
context
,
panel
)
{
$
.
vifib
.
onepanel
=
function
(
context
,
panel
)
{
var
page
=
$
(
'
<div data-role="page"></div>
'
),
var
page
=
$
(
'
<div data-role="page"></div>
'
),
content
=
$
(
'
<div data-role="content"></div>
'
),
content
=
$
(
'
<div data-role="content"></div>
'
),
...
@@ -46,12 +63,14 @@
...
@@ -46,12 +63,14 @@
return
$
(
page
);
return
$
(
page
);
};
};
// create number of panels contain in the list [panels], but with a maximum of [max]
$
.
vifib
.
multipanel
=
function
(
panels
,
max
)
{
$
.
vifib
.
multipanel
=
function
(
panels
,
max
)
{
var
page
=
$
(
'
<div data-role="page"></div>
'
)
var
page
=
$
(
'
<div data-role="page"></div>
'
)
.
append
(
$
.
vifib
.
makecontent
(
panels
,
max
));
.
append
(
$
.
vifib
.
makecontent
(
panels
,
max
));
return
$
(
page
);
return
$
(
page
);
};
};
// replace a panel with another [panel], without refresh the page
$
.
vifib
.
replacepanel
=
function
(
context
,
panel
)
{
$
.
vifib
.
replacepanel
=
function
(
context
,
panel
)
{
var
data
=
panel
.
hasOwnProperty
(
'
data
'
)
?
panel
.
data
:
{};
var
data
=
panel
.
hasOwnProperty
(
'
data
'
)
?
panel
.
data
:
{};
if
(
context
.
data
(
'
type
'
)
!==
'
panel
'
)
{
if
(
context
.
data
(
'
type
'
)
!==
'
panel
'
)
{
...
@@ -64,6 +83,7 @@
...
@@ -64,6 +83,7 @@
}
}
};
};
// return a panel wrap in a grid block
$
.
vifib
.
makepanel
=
function
(
panel
,
data
,
index
,
name
)
{
$
.
vifib
.
makepanel
=
function
(
panel
,
data
,
index
,
name
)
{
var
blockname
=
[
var
blockname
=
[
'
ui-block-a
'
,
'
ui-block-a
'
,
...
@@ -77,6 +97,7 @@
...
@@ -77,6 +97,7 @@
return
divpane
;
return
divpane
;
};
};
// create and return grid of panels
$
.
vifib
.
makecontent
=
function
(
panels
,
max
)
{
$
.
vifib
.
makecontent
=
function
(
panels
,
max
)
{
var
i
,
j
,
var
i
,
j
,
pancontext
,
pancontext
,
...
@@ -102,6 +123,7 @@
...
@@ -102,6 +123,7 @@
return
divcontent
;
return
divcontent
;
};
};
// remove all id element in the page and call changepage of jqm
$
.
vifib
.
changepage
=
function
(
page
)
{
$
.
vifib
.
changepage
=
function
(
page
)
{
$
(
'
[id^=panel]
'
).
remove
();
$
(
'
[id^=panel]
'
).
remove
();
$
(
'
#slider
'
).
remove
();
$
(
'
#slider
'
).
remove
();
...
@@ -113,6 +135,7 @@
...
@@ -113,6 +135,7 @@
});
});
};
};
// return the nextpanel (orientation: from left to right)
$
.
vifib
.
nextpanel
=
function
(
context
)
{
$
.
vifib
.
nextpanel
=
function
(
context
)
{
var
panelname
=
[[
'
center
'
],
[
'
left
'
,
'
right
'
],
[
'
left
'
,
'
center
'
,
'
right
'
]],
var
panelname
=
[[
'
center
'
],
[
'
left
'
,
'
right
'
],
[
'
left
'
,
'
center
'
,
'
right
'
]],
nbpanel
=
$
(
'
:jqmData(role=content)
'
).
data
(
'
nbpanel
'
)
===
undefined
?
1
:
$
(
'
:jqmData(role=content)
'
).
data
(
'
nbpanel
'
),
nbpanel
=
$
(
'
:jqmData(role=content)
'
).
data
(
'
nbpanel
'
)
===
undefined
?
1
:
$
(
'
:jqmData(role=content)
'
).
data
(
'
nbpanel
'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment