Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1949698
template_manager.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Oct 29, 7:13 AM
Size
3 KB
Mime Type
text/plain
Expires
Sat, Oct 31, 7:13 AM (10 h, 48 m)
Engine
blob
Format
Raw Data
Handle
963515
Attached To
rINP In-Portal
template_manager.js
View Options
function
TemplateManager
(
$edit_url
,
$browse_url
,
$edting_mode
)
{
this
.
_editUrl
=
$edit_url
;
this
.
browseUrl
=
$browse_url
;
this
.
editingMode
=
$edting_mode
;
// from 1 to 4
this
.
_blocks
=
{};
this
.
_blockOrder
=
Array
();
var
$template_manager
=
this
;
$
(
document
).
ready
(
function
()
{
$template_manager
.
searchBlocks
();
if
(
!
$template_manager
.
editingMode
)
{
return
;
}
// show special toolbar when in any of 4 browse modes
var
$head_frame
=
getFrame
(
'head'
);
var
$extra_toolbar
=
$head_frame
.
$
(
'div.front-extra-toolbar'
).
clone
();
// clone to keep original untouched
$
(
'a'
,
$extra_toolbar
).
each
(
function
()
{
var
$editing_mode
=
$
(
this
).
attr
(
'href'
).
replace
(
'#'
,
''
);
$
(
this
).
attr
(
'href'
,
$template_manager
.
browseUrl
.
replace
(
'#EDITING_MODE#'
,
$editing_mode
));
if
(
$editing_mode
==
$template_manager
.
editingMode
)
{
$
(
this
).
parents
(
'td:first'
).
addClass
(
'button-active'
).
prevAll
(
'td:first'
).
addClass
(
'button-active'
);
}
}
);
$head_frame
.
$
(
'#extra_toolbar'
).
html
(
$extra_toolbar
.
html
()
);
if
(
$template_manager
.
editingMode
==
2
)
{
// Layout Mode
$
(
'div.movable-area'
).
sortable
(
{
placeholder
:
'move-helper'
,
handle
:
'.movable-header'
,
items
:
'div.movable-element'
,
connectWith
:
[
'div.movable-area'
],
start
:
function
(
e
,
ui
)
{
ui
.
placeholder
.
height
(
ui
.
item
.
height
()
);
}
}
);
}
}
);
}
TemplateManager
.
prototype
.
onBtnClick
=
function
(
$e
,
$element
)
{
var
$id
=
$element
.
id
.
replace
(
/_btn$/
,
''
);
var
$block_info
=
this
.
_blocks
[
$id
];
var
$url
=
this
.
_editUrl
.
replace
(
'#BLOCK#'
,
$block_info
.
block_name
+
':'
+
$block_info
.
function_name
).
replace
(
'#EVENT#'
,
'OnLoadBlock'
);
openSelector
(
'theme-file'
,
$url
);
$e
.
stopPropagation
();
}
TemplateManager
.
prototype
.
onMouseOver
=
function
(
$e
,
$element
)
{
$
(
$element
).
addClass
(
'block-edit-btn-container-over'
);
$e
.
stopPropagation
();
}
TemplateManager
.
prototype
.
onMouseOut
=
function
(
$e
,
$element
)
{
$
(
$element
).
removeClass
(
'block-edit-btn-container-over'
);
$e
.
stopPropagation
();
}
TemplateManager
.
prototype
.
searchBlocks
=
function
()
{
$
(
'div'
).
each
(
function
()
{
var
$id
=
$
(
this
).
attr
(
'id'
);
if
(
!
$id
||
$id
.
match
(
/parser_block\[.*\].*_btn$/
)
||
!
$id
.
match
(
/parser_block\[.*\]/
))
{
// skip other divs
return
true
;
}
TemplateManager
.
prototype
.
registerBlock
.
call
(
aTemplateManager
,
this
);
}
);
}
TemplateManager
.
prototype
.
registerBlock
=
function
(
$element
)
{
var
$params
=
$element
.
getAttribute
(
'params'
).
split
(
':'
);
this
.
_blocks
[
$element
.
id
]
=
{
block_name
:
$params
[
0
],
function_name
:
$params
[
1
]
};
var
$btn
=
document
.
getElementById
(
$element
.
id
+
'_btn'
);
$
(
$btn
).
bind
(
'click'
,
function
(
ev
)
{
TemplateManager
.
prototype
.
onBtnClick
.
call
(
aTemplateManager
,
ev
,
this
);
}
);
$
(
$element
).
bind
(
'mouseover'
,
function
(
ev
)
{
TemplateManager
.
prototype
.
onMouseOver
.
call
(
aTemplateManager
,
ev
,
this
);
}
);
$
(
$element
).
bind
(
'mouseout'
,
function
(
ev
)
{
TemplateManager
.
prototype
.
onMouseOut
.
call
(
aTemplateManager
,
ev
,
this
);
}
);
this
.
_blockOrder
.
push
(
$element
.
id
);
}
Event Timeline
Log In to Comment