From cc23bbddb8f2367f33e6291b13354c4cd98cd97b Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 22 Sep 2011 21:55:25 -0400 Subject: Fixes #3795 not inserting the file title when embeding a file and tweaked css - thanks to slyhne --- mod/embed/views/default/embed/css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/embed/views') diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 150dc8733..5750c05c0 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -8,7 +8,7 @@ .embed-wrapper { width: 730px; min-height: 400px; - margin: 5px; + margin: 10px; } .embed-wrapper h2 { color: #333333; -- cgit v1.2.3 From 43f82db7fe8cab6b035fb66b307e5466cb5b3aa5 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 24 Sep 2011 22:11:43 -0400 Subject: Fixes #3845 added ie7 css view and tested all current hacks for ie7 --- engine/lib/views.php | 1 + mod/embed/views/default/embed/css.php | 2 +- views/default/css/elements/core.php | 4 - views/default/css/elements/navigation.php | 4 +- views/default/css/ie.php | 119 +----------------------------- views/default/css/ie6.php | 8 +- views/default/css/ie7.php | 49 ++++++++++++ views/default/page/elements/head.php | 6 +- 8 files changed, 61 insertions(+), 132 deletions(-) create mode 100644 views/default/css/ie7.php (limited to 'mod/embed/views') diff --git a/engine/lib/views.php b/engine/lib/views.php index 9a236508f..3b9448c71 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1553,6 +1553,7 @@ function elgg_views_boot() { elgg_register_simplecache_view('css/elgg'); elgg_register_simplecache_view('css/ie'); elgg_register_simplecache_view('css/ie6'); + elgg_register_simplecache_view('css/ie7'); elgg_register_simplecache_view('js/elgg'); elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.2.min.js', 'head'); diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 5750c05c0..03373da2b 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -8,7 +8,7 @@ .embed-wrapper { width: 730px; min-height: 400px; - margin: 10px; + margin: 15px; } .embed-wrapper h2 { color: #333333; diff --git a/views/default/css/elements/core.php b/views/default/css/elements/core.php index af4a1882a..627cae55c 100644 --- a/views/default/css/elements/core.php +++ b/views/default/css/elements/core.php @@ -98,8 +98,4 @@ position: relative; display: inline-block; - - /* Inline-block: IE 6, 7 */ - zoom: 1; - *display: inline; } diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php index 9386fa27b..bee1312ec 100644 --- a/views/default/css/elements/navigation.php +++ b/views/default/css/elements/navigation.php @@ -98,7 +98,7 @@ .elgg-breadcrumbs > li { display: inline-block; } -.elgg-breadcrumbs > li:after{ +.elgg-breadcrumbs > li:after { content: "\003E"; padding: 0 4px; font-weight: normal; @@ -412,7 +412,7 @@ .elgg-menu-footer > li, .elgg-menu-footer > li > a { display: inline-block; - color:#999; + color: #999; } .elgg-menu-footer > li:after { diff --git a/views/default/css/ie.php b/views/default/css/ie.php index c5edefd4c..d20bb4d59 100644 --- a/views/default/css/ie.php +++ b/views/default/css/ie.php @@ -1,121 +1,4 @@ /** - * CSS for Internet Explorer for versions > ie6 + * CSS for IE8 and above */ -* {zoom: 1;} /* trigger hasLayout in IE */ - -/* site menu drop-down for IE7 */ -.elgg-page-header { - z-index: 1; -} - -.navigation li a:hover ul {display:block; position:absolute; top:21px; left:0;} -.navigation li a:hover ul li a {display:block;} -.navigation li.navigation-more ul li a {width:150px;background-color: #dedede;} - -.clearfix { display: block; } -.hidden.clearfix { display: none; } -#elgg-page-contents {overflow: hidden;} /* remove horizontal scroll on riverdash */ -#breadcrumbs {top:-2px; margin-bottom: 5px;} - -/* entity list views */ -.entity-metadata {max-width: 300px;} -.entity-edit {float:right;} -.access_level {float:left;} -.elgg-image-block .entity-metadata { - min-width:400px; - text-align: right; -} - -/* profile */ -.elgg-tabs.profile .profile_name {margin-left: -260px;} -#profile_content .river_comment_form.hidden .input-text { width:510px; } - -/* notifications */ -.friends-picker-navigation {margin:0;padding:0;} -.friends-picker-container h3 {margin:0;padding:0;line-height: 1em;} - -/* private messages */ -#elgg-topbar-contents a.privatemessages.new span { - display:block; - padding:1px; - position:relative; - text-align:center; - float:left; - top:-1px; - right:auto; -} -#elgg-topbar-contents a.privatemessages.new {padding:0 0 0 20px;} -#elgg-topbar-contents a.privatemessages:hover {background-position:left 2px;} -#elgg-topbar-contents a.privatemessages.new:hover {background-position: left 2px;} - -/* riverdashboard mod rules */ -#riverdashboard_updates {clear:both;} -#riverdashboard_updates a.update_link {margin:0 0 9px 0;} -.riverdashboard_filtermenu {margin:10px 0 0 0;} -.river_comment_form.hidden .input-text { - width:530px; - float:left; -} -.river_link_divider { - width:10px; - text-align: center; -} - -/* shared access */ -.shared_access_collection h2.shared_access_name {margin-top:-15px;} - -/* dropdown login */ -*:first-child+html #login-dropdown #signin-button { - line-height:10px; -} -*:first-child+html #login-dropdown #signin-button a.signin span { - background-position:-150px -54px; -} -*:first-child+html #login-dropdown #signin-button a.signin.menu-open span { - background-position:-150px -74px; -} - -/* Gallery */ -.elgg-gallery-fluid > li { - float: left; - margin: 2px; -} - - -/* navigation */ -.elgg-breadcrumbs > li { - display: inline; -} - -.elgg-breadcrumbs > li > a { - display: inline; - padding-right: 4px; - margin-right: 4px; - border-right: 1px solid #bababa; -} - -.elgg-menu-title > li { - display: block; -} - -.elgg-menu-title > li > a { - display: block; -} - -.elgg-menu-footer > li > a { - display: inline; -} - -.elgg-menu-river > li { - display: inline; -} - -li:hover > .elgg-menu-site-more { - display: none; -} - -/* admin */ -.elgg-menu-footer li { - display: inline; -} \ No newline at end of file diff --git a/views/default/css/ie6.php b/views/default/css/ie6.php index f8ed208f6..cf49d33f2 100644 --- a/views/default/css/ie6.php +++ b/views/default/css/ie6.php @@ -1,15 +1,11 @@ /** - * elgg_layout css for Internet Explorer6 - * @uses $vars['wwwroot'] The site URL -*/ + * CSS for IE6 + */ * {zoom: 1;} /* trigger hasLayout in IE */ /* main nav drop-down */ #elgg-header {z-index:1;} -.navigation li a:hover ul {display:block; position:absolute; top:21px; left:0;} -.navigation li a:hover ul li a {display:block;} -.navigation li.navigation-more ul li a {width:150px;background-color: #dedede;} /* @todo check this one */ .elgg-button-delete a { background-position-y: 2px; } diff --git a/views/default/css/ie7.php b/views/default/css/ie7.php new file mode 100644 index 000000000..91d23823f --- /dev/null +++ b/views/default/css/ie7.php @@ -0,0 +1,49 @@ +/** + * CSS for IE7 + */ + +/* trigger hasLayout in IE */ +* { + zoom: 1; +} + +/* site menu drop-down z-index fix for IE7 */ +.elgg-page-header { + z-index: 1; +} + +/* inline-block fixes */ +.elgg-gallery > li, +.elgg-button, +.elgg-icon, +.elgg-menu-hz > li, +.elgg-menu-hz > li:after, +.elgg-menu-hz > li > a, +.elgg-menu-hz > li > span, +.elgg-breadcrumbs > li, +.elgg-menu-footer > li > a, +.elgg-menu-footer li { + display: inline; +} + +/* IE7 does not support :after */ +.elgg-breadcrumbs > li > a { + display: inline; + padding-right: 4px; + margin-right: 4px; + border-right: 1px solid #bababa; +} +.elgg-menu-footer li, +.elgg-menu-user li { + padding-left: 4px; + padding-right: 4px; +} + +/* longtext menu would not display horizontally without this */ +.elgg-menu-longtext { + width: 100%; +} +.elgg-menu-longtext li { + width: 100px; + float: right; +} diff --git a/views/default/page/elements/head.php b/views/default/page/elements/head.php index 8776f07a7..e968e95ce 100644 --- a/views/default/page/elements/head.php +++ b/views/default/page/elements/head.php @@ -48,11 +48,15 @@ $release = get_version(true); - + -- cgit v1.2.3 From c7b0817dabd1ea596086b03569d4480355e5f721 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 12:42:00 -0400 Subject: using the menu system for the embed tabs and adding a reusable select list view --- mod/embed/languages/en.php | 1 - mod/embed/start.php | 132 ++++++++++++---------- mod/embed/views/default/embed/item.php | 31 +++++ mod/embed/views/default/embed/layout.php | 33 ++++++ mod/embed/views/default/embed/list.php | 61 ++++++++++ mod/embed/views/default/js/embed/embed.php | 10 +- mod/embed/views/default/navigation/menu/embed.php | 21 ++++ mod/file/start.php | 21 +++- 8 files changed, 239 insertions(+), 71 deletions(-) create mode 100644 mod/embed/views/default/embed/item.php create mode 100644 mod/embed/views/default/embed/layout.php create mode 100644 mod/embed/views/default/embed/list.php create mode 100644 mod/embed/views/default/navigation/menu/embed.php (limited to 'mod/embed/views') diff --git a/mod/embed/languages/en.php b/mod/embed/languages/en.php index 287d34ca1..6ae99a56f 100644 --- a/mod/embed/languages/en.php +++ b/mod/embed/languages/en.php @@ -5,7 +5,6 @@ */ $english = array( - 'media:insert' => 'Embed content', 'embed:embed' => 'Embed', 'embed:media' => 'Embed content', 'embed:instructions' => 'Click on any file to embed it into your content.', diff --git a/mod/embed/start.php b/mod/embed/start.php index 6c26163e9..a87776c7e 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -15,6 +15,7 @@ function embed_init() { elgg_extend_view('css/elgg', 'embed/css'); elgg_register_plugin_hook_handler('register', 'menu:longtext', 'embed_longtext_menu'); + elgg_register_plugin_hook_handler('register', 'menu:embed', 'embed_select_tab', 1000); // Page handler for the modal media embed elgg_register_page_handler('embed', 'embed_page_handler'); @@ -40,7 +41,7 @@ function embed_longtext_menu($hook, $type, $items, $vars) { $items[] = ElggMenuItem::factory(array( 'name' => 'embed', 'href' => "embed", - 'text' => elgg_echo('media:insert'), + 'text' => elgg_echo('embed:media'), 'rel' => 'lightbox', 'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}", 'priority' => 10, @@ -54,68 +55,83 @@ function embed_longtext_menu($hook, $type, $items, $vars) { } /** - * Serves pages for upload and embed. + * Select the correct embed tab for display * - * @param $page + * @param string $hook + * @param string $type + * @param array $items + * @param array $vars */ -function embed_page_handler($page) { - if (!isset($page[0])) { - $page[0] = 'embed'; +function embed_select_tab($hook, $type, $items, $vars) { + + $tab_name = array_pop(explode('/', full_url())); + foreach ($items as $item) { + if ($item->getName() == $tab_name) { + $item->setSelected(); + elgg_set_config('embed_tab', $item); + } } - switch ($page[0]) { - case 'upload': - echo elgg_view('embed/upload'); - break; - case 'embed': - default: - // trigger hook to get section tabs - // use views for embed/section/ - // listing - // item - // default to embed/listing | item if not found. - - // @todo the menu system is good for registering and sorting, but not great for - // displaying tabs. - // Pulling in the menu manually and passing it through the embed/tabs view. - // We should work on making it easier to use tabs through the menu system, then fix - // this mess. - $menus = get_config('menus'); - $menu = $menus['embed:sections']; - - $sections = array(); - $upload_sections = array(); - - foreach ($menu as $item) { - switch ($item->section) { - case 'upload': - $upload_sections[$item->getName()] = array( - 'name' => $item->getText(), - ); - break; - - default: - $sections[$item->getName()] = array( - 'name' => $item->getText(), - ); - break; - } - } - - $active_section = get_input('active_section', ''); - $active_section = preg_replace('[\W]', '', $active_section); - $internal_id = get_input('internal_id', ''); - $internal_id = preg_replace('[\W]', '', $internal_id); - - echo elgg_view('embed/embed', array( - 'sections' => $sections, - 'active_section' => $active_section, - 'upload_sections' => $upload_sections, - 'internal_id' => $internal_id - )); - break; + if (!elgg_get_config('embed_tab') && count($items) > 0) { + $items[0]->setSelected(); + elgg_set_config('embed_tab', $items[0]); } +} + +/** + * Serves the content for the embed lightbox + * + * @param array $page URL segments + */ +function embed_page_handler($page) { + + echo elgg_view('embed/layout'); // exit because this is in a modal display. exit; -} \ No newline at end of file +} + +/** + * A special listing function for selectable content + * + * This calls a custom list view for entities. + * + * @param array $entities Array of ElggEntity objects + * @param array $vars Display parameters + * @return string + */ +function embed_list_items($entities, $vars = array()) { + + $defaults = array( + 'items' => $entities, + 'list_class' => 'elgg-list-entity', + ); + + $vars = array_merge($defaults, $vars); + + return elgg_view('embed/list', $vars); +} + +/** + * Set the options for the list of embedable content + * + * @param array $options + * @return array + */ +function embed_get_list_options($options = array()) { + + if (elgg_get_page_owner_guid()) { + $container_guid = elgg_get_page_owner_guid(); + } else { + $container_guid = elgg_get_logged_in_user_guid(); + } + + $defaults = array( + 'limit' => 6, + 'container_guid' => $container_guid, + ); + + $options = array_merge($defaults, $options); + + return $options; +} diff --git a/mod/embed/views/default/embed/item.php b/mod/embed/views/default/embed/item.php new file mode 100644 index 000000000..a64a67d8b --- /dev/null +++ b/mod/embed/views/default/embed/item.php @@ -0,0 +1,31 @@ +" . $entity->title . ""; + +$icon = "getIconURL('small')}\" />"; + +$embed_code = elgg_view('output/url', array( + 'href' => $entity->getURL(), + 'title' => $title, + 'text' => $icon, + 'encode_text' => FALSE +)); + + +echo "
getGUID()}\">"; +echo elgg_view_image_block($image, $body); +echo '
'; + +// @todo JS 1.8: is this approach better than inline js? +echo ""; diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php new file mode 100644 index 000000000..73c26810d --- /dev/null +++ b/mod/embed/views/default/embed/layout.php @@ -0,0 +1,33 @@ +getData('tab_type')) { + case 'select': + $tab = elgg_list_entities( + embed_get_list_options($selected->getData('options')), + 'elgg_get_entities', + 'embed_list_items' + ); + if (!$tab) { + $tab = elgg_echo('embed:no_section_content'); + } + break; + case 'upload': + $tab = elgg_view($selected->getData('view'), $vars); + break; +} + +echo << + $title + $menu + $tab + +HTML; diff --git a/mod/embed/views/default/embed/list.php b/mod/embed/views/default/embed/list.php new file mode 100644 index 000000000..e36280e88 --- /dev/null +++ b/mod/embed/views/default/embed/list.php @@ -0,0 +1,61 @@ + element + * @uses $vars['item_class'] Additional CSS class for the
  • elements + */ + +$items = $vars['items']; +$offset = $vars['offset']; +$limit = $vars['limit']; +$count = $vars['count']; + +$offset_key = elgg_extract('offset_key', $vars, 'offset'); + +$list_class = 'elgg-list'; +if (isset($vars['list_class'])) { + $list_class = "$list_class {$vars['list_class']}"; +} + +$item_class = 'elgg-item'; +if (isset($vars['item_class'])) { + $item_class = "$item_class {$vars['item_class']}"; +} + +$html = ""; +$nav = ""; + +if ($count) { + $nav .= elgg_view('navigation/pagination', array( + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + 'offset_key' => $offset_key, + )); +} + +if (is_array($items) && count($items) > 0) { + $html .= "
      "; + foreach ($items as $item) { + $id = "elgg-{$item->getType()}-{$item->getGUID()}"; + $html .= "
    • "; + $html .= elgg_view('embed/item', array('entity' => $item)); + $html .= '
    • '; + } + $html .= '
    '; +} + +$html .= $nav; + +echo $html; diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index e9e08f9a0..49c277b69 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -15,9 +15,9 @@ elgg.embed.init = function() { }); // special pagination helper for lightbox - $('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.pagination); + $('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.loadContent); - $('.embed-section').live('click', elgg.embed.loadTab); + $('.embed-section').live('click', elgg.embed.loadContent); $('.embed-upload .elgg-form').live('submit', elgg.embed.submit); } @@ -87,7 +87,7 @@ elgg.embed.submit = function(event) { * @param {Object} event * @return void */ -elgg.embed.pagination = function(event) { +elgg.embed.loadContent = function(event) { $('.embed-wrapper').parent().load($(this).attr('href')); event.preventDefault(); } @@ -99,9 +99,7 @@ elgg.embed.pagination = function(event) { * @return void */ elgg.embed.loadTab = function(event) { - var section = $(this).attr('id'); - var url = elgg.config.wwwroot + 'embed/embed?active_section=' + section; - $('.embed-wrapper').parent().load(url); + $('.embed-wrapper').parent().load($(this).attr('href')); event.preventDefault(); } diff --git a/mod/embed/views/default/navigation/menu/embed.php b/mod/embed/views/default/navigation/menu/embed.php new file mode 100644 index 000000000..36cedc47e --- /dev/null +++ b/mod/embed/views/default/navigation/menu/embed.php @@ -0,0 +1,21 @@ + $menu_item->getText(), + 'url' => 'embed/tab/' . $menu_item->getName(), + 'url_class' => 'embed-section', + 'selected' => $menu_item->getSelected(), + ); + } +} + +echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/file/start.php b/mod/file/start.php index 749d7a519..16ce0e233 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -61,19 +61,28 @@ function file_init() { $item = ElggMenuItem::factory(array( 'name' => 'file', 'text' => elgg_echo('file'), - 'href' => '#', - 'section' => 'select' + 'section' => 'select', + 'data' => array( + 'tab_type' => 'select', + 'options' => array( + 'type' => 'object', + 'subtype' => 'file', + ), + ), )); - elgg_register_menu_item('embed:sections', $item); + elgg_register_menu_item('embed', $item); $item = ElggMenuItem::factory(array( 'name' => 'file_upload', 'text' => elgg_echo('file:upload'), - 'href' => '#', - 'section' => 'upload' + 'section' => 'upload', + 'data' => array( + 'tab_type' => 'upload', + 'view' => 'embed/file_upload/content', + ), )); - elgg_register_menu_item('embed:sections', $item); + elgg_register_menu_item('embed', $item); } /** -- cgit v1.2.3 From f352b05780a1896302d5a25936477b371c0f4dfd Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 14:35:10 -0400 Subject: removed unnecessary code --- mod/embed/views/default/embed/css.php | 264 ---------------------- mod/embed/views/default/embed/embed.php | 45 ---- mod/embed/views/default/embed/item.php | 2 +- mod/embed/views/default/embed/list.php | 3 - mod/embed/views/default/embed/tabs.php | 40 ---- mod/embed/views/default/group/default/embed.php | 5 - mod/embed/views/default/js/embed/embed.php | 14 +- mod/embed/views/default/object/default/embed.php | 6 - mod/embed/views/default/object/file/embed.php | 16 -- mod/embed/views/default/object/file/embedlist.php | 11 - mod/embed/views/default/site/default/embed.php | 5 - mod/embed/views/default/user/default/embed.php | 5 - 12 files changed, 2 insertions(+), 414 deletions(-) delete mode 100644 mod/embed/views/default/embed/embed.php delete mode 100644 mod/embed/views/default/embed/tabs.php delete mode 100644 mod/embed/views/default/group/default/embed.php delete mode 100644 mod/embed/views/default/object/default/embed.php delete mode 100644 mod/embed/views/default/object/file/embed.php delete mode 100644 mod/embed/views/default/object/file/embedlist.php delete mode 100644 mod/embed/views/default/site/default/embed.php delete mode 100644 mod/embed/views/default/user/default/embed.php (limited to 'mod/embed/views') diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 03373da2b..f654a208a 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -31,267 +31,3 @@ .embed-wrapper .elgg-image-block:hover { background-color: #eee; } - -/*************** - Form -******************/ -/* input field classes */ -.embed-wrapper .elgg-input-text, -.embed-wrapper .elgg-input-tags { - font: 120% Arial, Helvetica, sans-serif; - padding: 5px; - border: 1px solid #ccc; - color:#666; - background-color: white; - - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; - - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; -} -.embed-wrapper .elgg-input-text:focus, -.embed-wrapper .elgg-input-tags:focus { - border: solid 1px #4690d6; - background: #e4ecf5; - color:#333; -} -.embed-wrapper .elgg-input-file { - background-color: white; -} - -.embed-wrapper label { - color:#333; -} - - - - -#facebox { - position: absolute; - top: 0; - left: 0; - z-index: 10000; - text-align: left; -} -#facebox .popup { - position: relative; -} -#facebox .body { - padding: 10px 15px 20px 15px; - background-color: white; - width: 730px; - min-height:400px; - - -webkit-border-radius: 8px; - -moz-border-radius: 8px; - border-radius: 8px; -} -#facebox .loading { - text-align: center; - padding: 100px 10px 100px 10px; -} -#facebox .image { - text-align: center; -} -#facebox .footer { - float: right; - width:22px; - height:22px; - margin:-4px 0 0 0; - padding:0; -} -#facebox .footer img.close_image { - background: url(mod/embed/images/close_button.gif) no-repeat left top; -} -#facebox .footer img.close_image:hover { - background: url(mod/embed/images/close_button.gif) no-repeat left -31px; -} -#facebox_overlay { - position: fixed; - top: 0px; - left: 0px; - height:100%; - width:100%; -} -.facebox_hide { - z-index:-100; -} -.facebox_overlayBG { - background-color: #000; - z-index: 9999; -} -* html #facebox_overlay { /* ie6 hack */ - position: absolute; - height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); -} - -#facebox .body .content h2 { - color:#333333; -} - - -/* embeded content links */ -.embeded_file.link { - display: inline; - margin-right: 5px; - padding-left: 14px; - background-repeat: no-repeat; - - -webkit-background-size: 12px 16px; - -moz-background-size: 12px 16px; - background-size: 12px 16px; -} - -/* entity listings */ -.embed_data .elgg-image img { - cursor: pointer; -} -.embed_data .elgg-image-block { - border-bottom:none; -} -.embed_modal_videolist .elgg-image img { - width:75px; - height:auto; -} -.embed_modal_document .embed_data .elgg-body { - margin-top:0; - margin-left:7px; -} -.embed_modal_tidypics .embed_data .elgg-body { - margin-top:11px; -} -.embed_modal_file .embed_data .elgg-body { - margin-top:0px; - margin-left:9px; -} -.embed_data .elgg-body { - width:auto; - margin-top:15px; - margin-left:15px; -} -.embed_data .elgg-image-block { - cursor:pointer; -} - -/* input field classes */ -#facebox .content .elgg-input-text, -#facebox .content .elgg-input-tags { - font: 120% Arial, Helvetica, sans-serif; - padding: 5px; - border: 1px solid #ccc; - color:#666; - background-color: white; - - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; - - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; -} -#facebox .content .elgg-input-text:focus, -#facebox .content .elgg-input-tags:focus { - border: solid 1px #4690d6; - background: #e4ecf5; - color:#333; -} -#facebox .content .elgg-input-file { - background-color: white; -} -#facebox .content p { - color:#333; -} -#facebox .content p.entity-title { - color:#666; -} -#facebox .content .elgg-image-block:hover { - background-color: #eee; -} -#facebox .content label { - color:#333; -} - - -/* *************************************** - ELGG TABBED PAGE NAVIGATION -*************************************** */ -#facebox .body .elgg-tabs { - margin-bottom:5px; - padding: 0; - border-bottom: 2px solid #ccc; - display:table; - width:100%; -} -#facebox .body .elgg-tabs ul { - list-style: none; - padding: 0; - margin: 0; -} -#facebox .body .elgg-tabs li { - float: left; - border: 2px solid #ccc; - border-bottom-width: 0; - background: #eee; - margin: 0 0 0 10px; - - -webkit-border-radius:5px 5px 0 0; - -moz-border-radius: 5px 5px 0 0; - border-raidus: 5px 5px 0 0; -} -#facebox .body .elgg-tabs a { - text-decoration: none; - display: block; - padding:3px 10px 0 10px; - text-align: center; - height:21px; - color:#999; -} -#facebox .body .elgg-tabs a:hover { - background: #dedede; - color:#666; -} -#facebox .body .elgg-tabs .selected { - border-color: #ccc; - background: white; -} -#facebox .body .elgg-tabs .selected a { - position: relative; - top: 2px; - background: white; -} - - - -/* Pagination (override core elgg css defaults) */ -#facebox .body .pagination { - float:right; -} -#facebox .body .pagination .pagination-number { - border:1px solid #999; - color:#666; -} -#facebox .body .pagination .pagination-number:hover { - background-color:#aaa; - color:black; -} -#facebox .body .pagination .pagination-previous, -#facebox .body .pagination .pagination-next { - border:1px solid #999; - color:#666; -} -#facebox .body .pagination .pagination-previous:hover, -#facebox .body .pagination .pagination-next:hover { - background-color:#aaa; - color:black; -} -#facebox .body .pagination .pagination-currentpage { - background-color:#666; - border:1px solid #666; - color:white; -} \ No newline at end of file diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php deleted file mode 100644 index 2bd329690..000000000 --- a/mod/embed/views/default/embed/embed.php +++ /dev/null @@ -1,45 +0,0 @@ - Section Display Name - * @uses string $vars['active_section'] Currently selected section_id - */ - -$sections = elgg_extract('sections', $vars, array()); -$active_section = elgg_extract('active_section', $vars, array_shift(array_keys($sections)), false); -$upload_sections = elgg_extract('upload_sections', $vars, array()); - -if (!$sections) { - $content = elgg_echo('embed:no_sections'); -} else { - $content = elgg_view_title(elgg_echo('embed:media')); - $content .= elgg_view('embed/tabs', $vars); - - $offset = (int)max(0, get_input('offset', 0)); - $limit = (int)get_input('limit', 5); - - // find the view to display - // @todo make it so you don't have to manually create views for each page - $view = "embed/$active_section/content"; - - $section_content = elgg_view($view, $vars); - - // build the items and layout. - if ($section_content) { - $content .= $section_content; - } else { - $content .= elgg_echo('embed:no_section_content'); - } -} - -echo '
    ' . $content . '
    '; - -if (isset($js)) { - echo ''; -} diff --git a/mod/embed/views/default/embed/item.php b/mod/embed/views/default/embed/item.php index a64a67d8b..c6faa450b 100644 --- a/mod/embed/views/default/embed/item.php +++ b/mod/embed/views/default/embed/item.php @@ -2,7 +2,7 @@ /** * Embeddable content list item view * - * @uses $vars['entity'] + * @uses $vars['entity'] ElggEntity object */ $entity = $vars['entity']; diff --git a/mod/embed/views/default/embed/list.php b/mod/embed/views/default/embed/list.php index e36280e88..c13639cff 100644 --- a/mod/embed/views/default/embed/list.php +++ b/mod/embed/views/default/embed/list.php @@ -9,9 +9,6 @@ * @uses $vars['limit'] Number of items per page * @uses $vars['count'] Number of items in the complete list * - * @uses $vars['pagination'] Show pagination? (default: true) - * @uses $vars['position'] Position of the pagination: before, after, or both - * @uses $vars['full_view'] Show the full view of the items (default: false) * @uses $vars['list_class'] Additional CSS class for the
      element * @uses $vars['item_class'] Additional CSS class for the
    • elements */ diff --git a/mod/embed/views/default/embed/tabs.php b/mod/embed/views/default/embed/tabs.php deleted file mode 100644 index 3f377fee5..000000000 --- a/mod/embed/views/default/embed/tabs.php +++ /dev/null @@ -1,40 +0,0 @@ - $section_info) { - $tab = array( - 'title' => $section_info['name'], - 'url' => '#', - 'url_class' => 'embed-section', - 'url_id' => $section_id, - ); - - if ($section_id == $active_section) { - $tab['selected'] = TRUE; - } - $tabs[] = $tab; -} - -// make sure upload is always the last tab -if ($upload_sections) { - $tabs[] = array( - 'title' => elgg_echo('embed:upload'), - 'url' => '#', - 'url_class' => 'embed-section', - 'url_id' => 'upload', - 'selected' => ($active_section == 'upload') - ); -} - -echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/embed/views/default/group/default/embed.php b/mod/embed/views/default/group/default/embed.php deleted file mode 100644 index bf51f0a7d..000000000 --- a/mod/embed/views/default/group/default/embed.php +++ /dev/null @@ -1,5 +0,0 @@ -getURL() .'">' . $vars['entity']->name . ''; - } -?> \ No newline at end of file diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 49c277b69..e60c6b367 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -1,4 +1,3 @@ -//"; diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index e60c6b367..37246ee8a 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -3,7 +3,7 @@ elgg.provide('elgg.embed'); elgg.embed.init = function() { // inserts the embed content into the textarea - $(".embed_data").live('click', elgg.embed.insert); + $(".embed-item").live('click', elgg.embed.insert); // caches the current textarea id $(".embed-control").live('click', function() { @@ -24,7 +24,7 @@ elgg.embed.init = function() { /** * Inserts data attached to an embed list item in textarea * - * @todo generalize lightbox closing and wysiwyg refreshing + * @todo generalize lightbox closing * * @param {Object} event * @return void @@ -32,10 +32,23 @@ elgg.embed.init = function() { elgg.embed.insert = function(event) { var textAreaId = elgg.embed.textAreaId; - var content = $(this).data('embed_code'); - $('#' + textAreaId).val($('#' + textAreaId).val() + ' ' + content + ' '); - - + // generalize this based on a css class attached to what should be inserted + var content = ' ' + $(this).find(".elgg-image").html() + ' '; + + + $('#' + textAreaId).val($('#' + textAreaId).val() + content); + $('#' + textAreaId).focus(); + $.fancybox.close(); @@ -68,7 +81,7 @@ elgg.embed.submit = function(event) { if (response.status >= 0) { // @todo - really this should forward to what the registered defined // For example, forward to images tab if an image was uploaded - var url = elgg.config.wwwroot + 'embed/embed?active_section=file'; + var url = elgg.config.wwwroot + 'embed/embed'; $('.embed-wrapper').parent().load(url); } } -- cgit v1.2.3 From bc292c96ac6b118bd7a99509fce1c11bb232aeb2 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 16:54:24 -0400 Subject: fixed the forwarding of an embed upload form --- mod/embed/views/default/js/embed/embed.php | 5 +- mod/file/views/default/embed/file/content.php | 61 ---------------------- .../views/default/embed/file_upload/content.php | 9 +++- 3 files changed, 9 insertions(+), 66 deletions(-) delete mode 100644 mod/file/views/default/embed/file/content.php (limited to 'mod/embed/views') diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 37246ee8a..6d4e2e4ea 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -79,9 +79,8 @@ elgg.embed.submit = function(event) { elgg.system_message(response.system_messages.success); } if (response.status >= 0) { - // @todo - really this should forward to what the registered defined - // For example, forward to images tab if an image was uploaded - var url = elgg.config.wwwroot + 'embed/embed'; + var forward = $('input[name=embed_forward]').val(); + var url = elgg.normalize_url('embed/tab/' + forward); $('.embed-wrapper').parent().load(url); } } diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php deleted file mode 100644 index eadcd1a6d..000000000 --- a/mod/file/views/default/embed/file/content.php +++ /dev/null @@ -1,61 +0,0 @@ - elgg_get_logged_in_user_guid(), - 'type_subtype_pair' => array('object' => 'file'), - 'count' => true -); - -$count = elgg_get_entities($options); - -if ($count) { - echo "
      "; - - unset($options['count']); - $items = elgg_get_entities($options); - - foreach ($items as $item) { - - // different entity types have different title attribute names. - $title = isset($item->name) ? $item->name : $item->title; - // don't let it be too long - $title = elgg_get_excerpt($title); - - $author_text = elgg_echo('byline', array($owner->name)); - $date = elgg_view_friendly_time($item->time_created); - - $subtitle = "$author_text $date"; - - $icon = "getIconURL($icon_size)}\" />"; - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $icon, - 'encode_text' => FALSE - )); - - $item_icon = elgg_view_entity_icon($item, $icon_size); - - $params = array( - 'title' => $title, - 'entity' => $item, - 'subtitle' => $subtitle, - 'tags' => FALSE, - ); - $list_body = elgg_view('object/elements/summary', $params); - - // @todo JS 1.8: is this approach better than inline js? - echo "
      getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '
      '; - echo ""; - } - - echo '
      '; -} \ No newline at end of file diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php index 13c18f745..a530b3194 100644 --- a/mod/file/views/default/embed/file_upload/content.php +++ b/mod/file/views/default/embed/file_upload/content.php @@ -9,7 +9,12 @@ $form_vars = array( ); $upload_content = elgg_view_form('file/upload', $form_vars); -echo "
      " . elgg_echo('embed:upload_type') . "$input
      "; echo "
      "; echo $upload_content; -echo "
      "; \ No newline at end of file +echo ""; + +// the tab we want to be forwarded to after upload is complete +echo elgg_view('input/hidden', array( + 'name' => 'embed_forward', + 'value' => 'file', +)); \ No newline at end of file -- cgit v1.2.3 From d7549a210074a29f004642d713ede6ce04703bcc Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 17:38:47 -0400 Subject: Updated the instructions --- mod/embed/README.txt | 236 +++++++---------------------- mod/embed/views/default/js/embed/embed.php | 25 ++- 2 files changed, 66 insertions(+), 195 deletions(-) (limited to 'mod/embed/views') diff --git a/mod/embed/README.txt b/mod/embed/README.txt index 33c9fff65..c7ce2e528 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -1,198 +1,74 @@ -Embed plugin - Point-and-click embedding using ECML. +Embed plugin CONTENTS: 1. Overview - 2. Extending Embed - 1. Registering and Populating Embed Sections - 2. Registering Upload Sections - 3. Advanced Layouts - 4. Javascript - 3. Other Editors and Embed + 2. Adding a Tab + 3. Populating a Select Tab + 4. Populating an Upload Tab + 5. Other WYSIWYG Editors and Embed 1. Overview The Embed plugin is a simple way to allow users to link to or embed their personal network content or third party resources in any text area. - - Embed includes support for the default input/longtext view, but is easily - extendable to include support for rich text editors like TinyMCE or CK - Editor. + The Embed plugin adds a menu item to the longtext menu. Clicking on this + link pops up a lightbox. The lightbox has two types of tabs: one for + selecting content to embed and one for uploading new content. -2. Extending Embed - The Embed plugin can be extended by other plugins using a combination - of plugin hooks and specific views. - - Plugins can register a new content section or a new upload section. - - Plugins can also provide special views for their embed section, if - they require something the default view doesn't provide. +2. Adding a Tab + The Embed plugin uses the menu system to manage its tabs. Use + elgg_register_menu_item() for the embed menu to add a new tab like this: + $item = ElggMenuItem::factory(array( + 'name' => 'file', + 'text' => elgg_echo('file'), + 'section' => 'select', + 'data' => array( + 'options' => array( + 'type' => 'object', + 'subtype' => 'file', + ), + ), + )); + elgg_register_menu_item('embed', $item); -2.1 Registering and Populating Embed Sections - Plugins providing embed content should reply to two hooks: embed_get_sections:all - and embed_get_items:$section_name. - - Embed emits the 'embed_get_sections' hook to populate the tabs of the modal display. - Plugins supporting embed should reply by pushing an array element to the passed - $value. - - Register plugins hooks like this: - - register_plugin_hook('embed_get_sections', 'all', 'my_plugin_embed_get_sections'); - - function my_plugin_embed_get_sections($hook, $type, $value, $params) { - $value['videolist'] = array( - 'name' => elgg_echo('my_plugin'), - 'layout' => 'list', - 'icon_size' => 'medium', - ); - - return $value; - } - - The index of the returned array is the id used for the Embed section. - - Options available in the array value are: - name => The friendly name to display in the tab - layout => The layout style to use. Layouts are found in the - embed/layouts/$layout and embed/item/$layout views. - Default supported layouts are list and gallery. - icon_size => The icon size to use for in the item list. - - - Embed emits the 'embed_get_items' hook to populate the embed section. Plugins - supporting embed should reply by returning an array of ElggEntities, which will - be formatted by Embed. If you need specific formatting for items, see section 2.3. - - register_plugin_hook('embed_get_items', 'videolist', 'videolist_embed_get_items'); - - function my_plugin_embed_get_items($hook, $type, $value, $params) { - $options = array( - 'owner_guid' => get_loggedin_userid(), - 'type_subtype_pair' => array('object' => 'my_plugin_type'), - 'count' => TRUE - ); - - if ($count = elgg_get_entities($options)) { - $value['count'] += $count; - - unset($options['count']); - $options['offset'] = $params['offset']; - $options['limit'] = $params['limit']; - - $items = elgg_get_entities($options); - - $value['items'] = array_merge($items, $value['items']); - } - - return $value; - } - - Values passed in $params are: - offset - Offset for entity list. - limit - Limit for entity list. - section - The current active section. - upload_sections - Valid upload sections. - internal_name - Internal name of the input field - - The function should return $value as: - items - An array of ElggEntities - count - The count of all available entities to embed - - In case other plugins want to mangle the value, be sure to - check for existing values before appending. + Parameters: + name: The unique name of the tab. + text: The text shown on the tab + section: 'select' for embed selection or 'upload' for uploading new content + data: an array of parameters for creating the tab and its content. See + the two sections below for data key values for the two tab types. + Select tab data parameters: + options: array of options passed to elgg_list_entities() -2.2 Registering Upload Sections - Embed includes a special tab, Upload, that allows users to immediatley - upload a new item. Like the embed sections, plugins can extend this - to add their own upload form. - - Embed emits the embed_get_upload_sections:all hook to populate the - dropdown in the upload tab. Plugins should respond to this hook - by returning an array with details about the upload section: - - register_plugin_hook('embed_get_upload_sections', 'all', 'my_plugin_embed_get_upload_sections'); - - function my_plugin_embed_get_upload_sections($hook, $type, $value, $params) { - $value['my_plugin'] = array( - 'name' => elgg_echo('my_plugin'), - 'view' => 'my_plugin/forms/embed_upload' - ); - - return $value; - } - - The array index is the ID of the upload section, and the values are: - name - The friendly name of the upload section - view - The view to use for the upload section's content - - The upload form view should use AJAX to upload a file and return - the user to the correct section or automatically insert the new upload - into the text area. See Tidypics as an example. - - -2.3 Advanced Layouts - By default, Embed will automatically format items returned by - embed_get_items hooks. If you need special formatting you can - override both the content and layout views. - - Embed looks for a section-specific views before defaulting to built - in formatting: - embed/$section/content - The content of the embed section - including all headers and navigation elements. - embed/$section/item/$layout - The content of the embed section - for the specific layout. Inserted - between navigation elements. - - Embed also supports adhoc layouts that can be shared among different plugins. - To use a specific layout, register the embed section with your own layout - and create the appropriate layout view: - - function my_plugin_embed_get_sections($hook, $type, $value, $params) { - $value['videolist'] = array( - 'name' => elgg_echo('my_plugin'), - 'layout' => 'shared_embed_layout', - 'icon_size' => 'medium', - ); - - return $value; - } - - Create the views 'embed/layouts/shared_embed_layout' and - 'embed/items/shared_embed_layout.' See the default list and - gallery layouts as examples. - - -2.4 Javascript - If you use a custom layout you need to provide a way to insert - the user's selection into the current editor. Usually this will be - an onClick event via Javascript. Embed provides a helper function for - this: - - elggEmbedInsertContent(content, textAreaId) - - Content is the pre-formatted content to insert into the text area, - and textAreaId is the name of the text area. This name is - sent via GET as 'internal_name.' - + Upload tab data parameters: + view: the view used to render the tab content + + See the file plugin for examples of registering both tab types. + + +3. Populating a Select Tab + Nothing should be required other than setting the options parameter array + when registering the tab. See the view embed/item to see how an entity is + rendered. + +4. Populating an Upload Tab + The view that is registered must be defined. It must include a form for + uploading the content. The form must be wrapped in a div with the class + .embed-upload. Somewhere in the view must be a hidden input field with the + name embed_hidden with its value be the name of the tab to forward the user + to when uploading is complete. + + See the view embed/file_upload/content for an example -3. Other Editors and Embed +5. Other WYSIWYG Editors and Embed Embed ships with support for the default input/longtext textarea. - Plugins replacing this view are expected to include Javascript to + Plugins replacing this view are expected to include JaVascript to allow embed to work with the new editors. - The elggEmbedInsertContent() JS function can be extened for custom - text editors by extending the embed/custom_insert_js view. Plugins - should extend this view with javascript code that inserts - content into the specific text area. Variables available within - this view are: - str content The content to insert. - str textAreaId The name of the textarea to receive the content. - - Note: Extend this view; don't override it. It is important to correctly - extend this view for compatibility across multiple plugins and textarea - states. Your custom JS should run without error no matter plugin order - or rich text editor status. See TinyMCE as an example of how to losely - extend this function. \ No newline at end of file + To add custom JavaScript into the Embed plugin's elgg.embed.insert() function, + override the view embed/custom_insert_js. The textarea jQuery object is + available as the variable textArea and the content to be inserted is the + variable content. See the TinyMCE plugin for an example of this view. \ No newline at end of file diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 6d4e2e4ea..840d8f89c 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -14,9 +14,9 @@ elgg.embed.init = function() { }); // special pagination helper for lightbox - $('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.loadContent); + $('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.forward); - $('.embed-section').live('click', elgg.embed.loadContent); + $('.embed-section').live('click', elgg.embed.forward); $('.embed-upload .elgg-form').live('submit', elgg.embed.submit); } @@ -31,25 +31,20 @@ elgg.embed.init = function() { */ elgg.embed.insert = function(event) { var textAreaId = elgg.embed.textAreaId; + var textArea = $('#' + textAreaId); // generalize this based on a css class attached to what should be inserted var content = ' ' + $(this).find(".elgg-image").html() + ' '; + textArea.val(textArea.val() + content); + textArea.focus(); + - $('#' + textAreaId).val($('#' + textAreaId).val() + content); - $('#' + textAreaId).focus(); - + $.fancybox.close(); event.preventDefault(); @@ -98,7 +93,7 @@ elgg.embed.submit = function(event) { * @param {Object} event * @return void */ -elgg.embed.loadContent = function(event) { +elgg.embed.forward = function(event) { $('.embed-wrapper').parent().load($(this).attr('href')); event.preventDefault(); } -- cgit v1.2.3 From fa04d6615760a014f7557f2d28ff864eebce8551 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 3 Oct 2011 21:30:30 -0400 Subject: removed the sections from the menu to provide more flexibility in tab ordering --- mod/embed/README.txt | 36 ++++++++++++---------- mod/embed/views/default/embed/css.php | 2 +- mod/embed/views/default/embed/layout.php | 25 +++++++-------- mod/embed/views/default/js/embed/embed.php | 2 +- mod/embed/views/default/navigation/menu/embed.php | 19 +++++------- mod/file/start.php | 6 ++-- .../views/default/embed/file_upload/content.php | 8 ++--- 7 files changed, 44 insertions(+), 54 deletions(-) (limited to 'mod/embed/views') diff --git a/mod/embed/README.txt b/mod/embed/README.txt index c7ce2e528..cecee08c0 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -13,8 +13,9 @@ CONTENTS: their personal network content or third party resources in any text area. The Embed plugin adds a menu item to the longtext menu. Clicking on this - link pops up a lightbox. The lightbox has two types of tabs: one for - selecting content to embed and one for uploading new content. + link pops up a lightbox. The lightbox supports lists of content for insertion + and uploading new content. + 2. Adding a Tab The Embed plugin uses the menu system to manage its tabs. Use @@ -23,7 +24,7 @@ CONTENTS: $item = ElggMenuItem::factory(array( 'name' => 'file', 'text' => elgg_echo('file'), - 'section' => 'select', + 'priority' => 10, 'data' => array( 'options' => array( 'type' => 'object', @@ -36,32 +37,33 @@ CONTENTS: Parameters: name: The unique name of the tab. text: The text shown on the tab - section: 'select' for embed selection or 'upload' for uploading new content - data: an array of parameters for creating the tab and its content. See - the two sections below for data key values for the two tab types. - - Select tab data parameters: - options: array of options passed to elgg_list_entities() - - Upload tab data parameters: - view: the view used to render the tab content + priority: Placement of the tab. + data: An array of parameters for creating the tab and its content. + When listing content using the embed list view, pass the options for the + elgg_list_entities() function as 'options'. + When using a custom view for listing content or for uploading new + content, pass the view name as 'view'. See the file plugin for examples of registering both tab types. -3. Populating a Select Tab +3. Populating a Content Select Tab Nothing should be required other than setting the options parameter array when registering the tab. See the view embed/item to see how an entity is rendered. + If creating a custom list, the
    • elements must have a class of .embed-item. + The HTML content that is inserted must use the class .elgg-image. + + 4. Populating an Upload Tab The view that is registered must be defined. It must include a form for - uploading the content. The form must be wrapped in a div with the class - .embed-upload. Somewhere in the view must be a hidden input field with the - name embed_hidden with its value be the name of the tab to forward the user - to when uploading is complete. + uploading the content. The form must .elgg-form-embed. Somewhere in the view + must be a hidden input field with the name embed_hidden with its value be + the name of the tab to forward the user to when uploading is complete. See the view embed/file_upload/content for an example + 5. Other WYSIWYG Editors and Embed Embed ships with support for the default input/longtext textarea. diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 324ed1038..034c0fcfe 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -8,7 +8,7 @@ .embed-wrapper { width: 730px; min-height: 400px; - margin: 15px; + margin: 20px 15px; } .embed-wrapper h2 { color: #333333; diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php index 73c26810d..c1e43f13c 100644 --- a/mod/embed/views/default/embed/layout.php +++ b/mod/embed/views/default/embed/layout.php @@ -8,20 +8,17 @@ $title = elgg_view_title(elgg_echo('embed:media')); $menu = elgg_view_menu('embed'); $selected = elgg_get_config('embed_tab'); -switch ($selected->getData('tab_type')) { - case 'select': - $tab = elgg_list_entities( - embed_get_list_options($selected->getData('options')), - 'elgg_get_entities', - 'embed_list_items' - ); - if (!$tab) { - $tab = elgg_echo('embed:no_section_content'); - } - break; - case 'upload': - $tab = elgg_view($selected->getData('view'), $vars); - break; +if ($selected->getData('view')) { + $tab = elgg_view($selected->getData('view'), $vars); +} else { + $tab = elgg_list_entities( + embed_get_list_options($selected->getData('options')), + 'elgg_get_entities', + 'embed_list_items' + ); + if (!$tab) { + $tab = elgg_echo('embed:no_section_content'); + } } echo << $menu_item->getText(), - 'url' => 'embed/tab/' . $menu_item->getName(), - 'url_class' => 'embed-section', - 'selected' => $menu_item->getSelected(), - ); - } +foreach ($vars['menu']['default'] as $menu_item) { + $tabs[] = array( + 'title' => $menu_item->getText(), + 'url' => 'embed/tab/' . $menu_item->getName(), + 'url_class' => 'embed-section', + 'selected' => $menu_item->getSelected(), + ); } echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/file/start.php b/mod/file/start.php index 16ce0e233..843ae0794 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -61,9 +61,8 @@ function file_init() { $item = ElggMenuItem::factory(array( 'name' => 'file', 'text' => elgg_echo('file'), - 'section' => 'select', + 'priority' => 10, 'data' => array( - 'tab_type' => 'select', 'options' => array( 'type' => 'object', 'subtype' => 'file', @@ -75,9 +74,8 @@ function file_init() { $item = ElggMenuItem::factory(array( 'name' => 'file_upload', 'text' => elgg_echo('file:upload'), - 'section' => 'upload', + 'priority' => 100, 'data' => array( - 'tab_type' => 'upload', 'view' => 'embed/file_upload/content', ), )); diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php index a530b3194..4d3db0d97 100644 --- a/mod/file/views/default/embed/file_upload/content.php +++ b/mod/file/views/default/embed/file_upload/content.php @@ -5,13 +5,9 @@ $form_vars = array( 'enctype' => 'multipart/form-data', - 'class' => 'elgg-form', + 'class' => 'elgg-form-embed', ); -$upload_content = elgg_view_form('file/upload', $form_vars); - -echo "
      "; -echo $upload_content; -echo "
      "; +echo elgg_view_form('file/upload', $form_vars); // the tab we want to be forwarded to after upload is complete echo elgg_view('input/hidden', array( -- cgit v1.2.3 From 9d5c00c78c0666a31485d870a1e657d4557b23c4 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 3 Oct 2011 21:56:14 -0400 Subject: using better insert class --- mod/embed/README.txt | 2 +- mod/embed/views/default/embed/item.php | 2 +- mod/embed/views/default/js/embed/embed.php | 2 +- mod/file/views/default/icon/object/file.php | 15 ++++++++++----- views/default/icon/default.php | 5 ++++- 5 files changed, 17 insertions(+), 9 deletions(-) (limited to 'mod/embed/views') diff --git a/mod/embed/README.txt b/mod/embed/README.txt index cecee08c0..51b120d96 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -53,7 +53,7 @@ CONTENTS: rendered. If creating a custom list, the
    • elements must have a class of .embed-item. - The HTML content that is inserted must use the class .elgg-image. + The HTML content that is inserted must use the class .embed-insert. 4. Populating an Upload Tab diff --git a/mod/embed/views/default/embed/item.php b/mod/embed/views/default/embed/item.php index 4087b7408..3060de879 100644 --- a/mod/embed/views/default/embed/item.php +++ b/mod/embed/views/default/embed/item.php @@ -34,6 +34,6 @@ $params = array( ); $body = elgg_view('object/elements/summary', $params); -$image = elgg_view_entity_icon($entity, 'small'); +$image = elgg_view_entity_icon($entity, 'small', array('link_class' => 'embed-insert')); echo elgg_view_image_block($image, $body); diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index bb80919a9..3126e12f7 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -34,7 +34,7 @@ elgg.embed.insert = function(event) { var textArea = $('#' + textAreaId); // generalize this based on a css class attached to what should be inserted - var content = ' ' + $(this).find(".elgg-image").html() + ' '; + var content = ' ' + $(this).find(".embed-insert").parent().html() + ' '; textArea.val(textArea.val() + content); textArea.focus(); diff --git a/mod/file/views/default/icon/object/file.php b/mod/file/views/default/icon/object/file.php index 6357d418f..7feba7af3 100644 --- a/mod/file/views/default/icon/object/file.php +++ b/mod/file/views/default/icon/object/file.php @@ -2,9 +2,10 @@ /** * File icon view * - * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method - * @uses $vars['size'] topbar, tiny, small, medium (default), large, master - * @uses $vars['href'] Optional override for link + * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method + * @uses $vars['size'] topbar, tiny, small, medium (default), large, master + * @uses $vars['href'] Optional override for link + * @uses $vars['link_class'] Optional CSS class added to img */ $entity = $vars['entity']; @@ -32,10 +33,14 @@ $img_src = elgg_format_url($img_src); $img = "\"$title\""; if ($url) { - echo elgg_view('output/url', array( + $params = array( 'href' => $url, 'text' => $img, - )); + ); + if (isset($vars['link_class'])) { + $params['class'] = $vars['link_class']; + } + echo elgg_view('output/url', $params); } else { echo $img; } diff --git a/views/default/icon/default.php b/views/default/icon/default.php index c5749ba04..3abd96b96 100644 --- a/views/default/icon/default.php +++ b/views/default/icon/default.php @@ -8,6 +8,7 @@ * @uses $vars['entity'] The entity the icon represents - uses getIconURL() method * @uses $vars['size'] topbar, tiny, small, medium (default), large, master * @uses $vars['href'] Optional override for link + * @uses $vars['img_class'] Optional CSS class added to img */ $entity = $vars['entity']; @@ -18,6 +19,8 @@ if (!in_array($vars['size'], $sizes)) { $vars['size'] = "medium"; } +$class = elgg_extract('img_class', $vars, ''); + if (isset($entity->name)) { $title = $entity->name; } else { @@ -30,7 +33,7 @@ if (isset($vars['href'])) { } $img_src = $entity->getIconURL($vars['size']); -$img = "\"$title\""; +$img = "\"$title\""; if ($url) { echo elgg_view('output/url', array( -- cgit v1.2.3 From 5c0bd8a19a294f178ddd6607dd3f624ca34fa5b7 Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 1 Nov 2011 19:36:27 -0400 Subject: added semi-colons after function expressions --- .../coding_standards/javascript_coding_standards.txt | 11 +++++++++++ js/lib/avatar_cropper.js | 6 +++--- js/lib/configuration.js | 2 +- js/lib/elgglib.js | 8 ++++---- js/lib/hooks.js | 8 ++++---- js/lib/ui.js | 14 +++++++------- js/lib/ui.widgets.js | 12 ++++++------ js/lib/userpicker.js | 10 +++++----- mod/blog/views/default/js/blog/save_draft.php | 4 ++-- mod/bookmarks/views/default/bookmarks/js.php | 2 +- mod/developers/views/default/js/developers/developers.php | 4 ++-- mod/embed/views/default/js/embed/embed.php | 8 ++++---- mod/messageboard/views/default/messageboard/js.php | 6 +++--- mod/thewire/views/default/js/thewire.php | 6 +++--- mod/tinymce/views/default/js/tinymce.php | 4 ++-- .../views/default/uservalidationbyemail/js.php | 2 +- 16 files changed, 59 insertions(+), 48 deletions(-) (limited to 'mod/embed/views') diff --git a/documentation/coding_standards/javascript_coding_standards.txt b/documentation/coding_standards/javascript_coding_standards.txt index 7d3b842ec..9939e80ab 100644 --- a/documentation/coding_standards/javascript_coding_standards.txt +++ b/documentation/coding_standards/javascript_coding_standards.txt @@ -1,2 +1,13 @@ *** JAVASCRIPT CODING STANDARDS *** +* Same formatting standards as PHP. + +* All functions should be in the elgg namespace. + +* Function expressions should end with a semi-colon: + + elgg.ui.toggles = function(event) { + event.preventDefault(); + $(target).slideToggle('medium'); + }; + diff --git a/js/lib/avatar_cropper.js b/js/lib/avatar_cropper.js index df6ba7866..fc32a0832 100644 --- a/js/lib/avatar_cropper.js +++ b/js/lib/avatar_cropper.js @@ -32,7 +32,7 @@ elgg.avatarCropper.init = function() { var selection = ias.getSelection(); elgg.avatarCropper.preview($('#user-avatar-cropper'), selection); } -} +}; /** * Handler for changing select area. @@ -57,7 +57,7 @@ elgg.avatarCropper.preview = function(img, selection) { marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); -} +}; /** * Handler for updating the form inputs after select ends @@ -71,6 +71,6 @@ elgg.avatarCropper.selectChange = function(img, selection) { $('input[name=x2]').val(selection.x2); $('input[name=y1]').val(selection.y1); $('input[name=y2]').val(selection.y2); -} +}; elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init); \ No newline at end of file diff --git a/js/lib/configuration.js b/js/lib/configuration.js index f724a2f01..6e221c957 100644 --- a/js/lib/configuration.js +++ b/js/lib/configuration.js @@ -7,4 +7,4 @@ elgg.provide('elgg.config'); */ elgg.get_site_url = function() { return elgg.config.wwwroot; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js index 628adccfc..d963a62be 100644 --- a/js/lib/elgglib.js +++ b/js/lib/elgglib.js @@ -467,7 +467,7 @@ elgg.parse_url = function(url, component, expand) { } } return results; -} +}; /** * Returns an object with key/values of the parsed query string. @@ -540,7 +540,7 @@ elgg.push_to_object_array = function(object, parent, value) { } return false; -} +}; /** * Tests if object[parent] contains child @@ -554,7 +554,7 @@ elgg.is_in_object_array = function(object, parent, value) { elgg.assertTypeOf('string', parent); return typeof(object[parent]) != 'undefined' && object[parent].indexOf(value) >= 0; -} +}; /** * Triggers the init hook when the library is ready @@ -569,4 +569,4 @@ elgg.initWhenReady = function() { elgg.trigger_hook('init', 'system'); elgg.trigger_hook('ready', 'system'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/js/lib/hooks.js b/js/lib/hooks.js index edfd28f24..7bac471f6 100644 --- a/js/lib/hooks.js +++ b/js/lib/hooks.js @@ -136,7 +136,7 @@ elgg.register_instant_hook = function(name, type) { elgg.assertTypeOf('string', type); return elgg.push_to_object_array(elgg.config.instant_hooks, name, type); -} +}; /** * Is this hook registered as an instant hook? @@ -146,7 +146,7 @@ elgg.register_instant_hook = function(name, type) { */ elgg.is_instant_hook = function(name, type) { return elgg.is_in_object_array(elgg.config.instant_hooks, name, type); -} +}; /** * Records that a hook has been triggered. @@ -156,7 +156,7 @@ elgg.is_instant_hook = function(name, type) { */ elgg.set_triggered_hook = function(name, type) { return elgg.push_to_object_array(elgg.config.triggered_hooks, name, type); -} +}; /** * Has this hook been triggered yet? @@ -166,7 +166,7 @@ elgg.set_triggered_hook = function(name, type) { */ elgg.is_triggered_hook = function(name, type) { return elgg.is_in_object_array(elgg.config.triggered_hooks, name, type); -} +}; elgg.register_instant_hook('init', 'system'); elgg.register_instant_hook('ready', 'system'); diff --git a/js/lib/ui.js b/js/lib/ui.js index 6cc1bc78a..16ef2dc96 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -25,7 +25,7 @@ elgg.ui.init = function () { if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } -} +}; /** * Toggles an element based on clicking a separate element @@ -43,7 +43,7 @@ elgg.ui.toggles = function(event) { var target = $(this).toggleClass('elgg-state-active').attr('href'); $(target).slideToggle('medium'); -} +}; /** * Pops up an element based on clicking a separate element @@ -105,7 +105,7 @@ elgg.ui.popsUp = function(event) { $('body') .die('click', elgg.ui.popupClose) .live('click', elgg.ui.popupClose); -} +}; /** * Catches clicks that aren't in a popup and closes all popups. @@ -143,7 +143,7 @@ elgg.ui.popupClose = function(event) { $('body').die('click', elgg.ui.popClose); } -} +}; /** * Toggles a child menu when the parent is clicked @@ -155,7 +155,7 @@ elgg.ui.toggleMenu = function(event) { $(this).siblings().slideToggle('medium'); $(this).toggleClass('elgg-menu-closed elgg-menu-opened'); event.preventDefault(); -} +}; /** * Initialize the hover menu @@ -215,7 +215,7 @@ elgg.ui.initHoverMenu = function(parent) { $(".elgg-menu-hover").fadeOut(); } }); -} +}; /** * Calls a confirm() and prevents default if denied. @@ -276,7 +276,7 @@ elgg.ui.initDatePicker = function() { } } }); -} +}; elgg.register_hook_handler('init', 'system', elgg.ui.init); elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.LoginHandler); \ No newline at end of file diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index fb256672a..6435d2147 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -65,7 +65,7 @@ elgg.ui.widgets.add = function(event) { } }); event.preventDefault(); -} +}; /** * Persist the widget's new position @@ -96,7 +96,7 @@ elgg.ui.widgets.move = function(event, ui) { // @hack fixes jquery-ui/opera bug where draggable elements jump ui.item.css('top', 0); ui.item.css('left', 0); -} +}; /** * Removes a widget from the layout @@ -134,7 +134,7 @@ elgg.ui.widgets.remove = function(event) { } }); event.preventDefault(); -} +}; /** * Toggle the collapse state of the widget @@ -146,7 +146,7 @@ elgg.ui.widgets.collapseToggle = function(event) { $(this).toggleClass('elgg-widget-collapsed'); $(this).parent().parent().find('.elgg-body').slideToggle('medium'); event.preventDefault(); -} +}; /** * Save a widget's settings @@ -178,7 +178,7 @@ elgg.ui.widgets.saveSettings = function(event) { } }); event.preventDefault(); -} +}; /** * Make all elements have the same min-height @@ -197,6 +197,6 @@ elgg.ui.widgets.equalHeight = function(selector) { } }) $(selector).css('min-height', maxHeight); -} +}; elgg.register_hook_handler('init', 'system', elgg.ui.widgets.init); diff --git a/js/lib/userpicker.js b/js/lib/userpicker.js index ae2add53f..8287ba91c 100644 --- a/js/lib/userpicker.js +++ b/js/lib/userpicker.js @@ -34,7 +34,7 @@ elgg.userpicker.init = function() { }); $('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser); -} +}; /** * Adds a user to the select user list @@ -59,7 +59,7 @@ elgg.userpicker.addUser = function(event, ui) { $(this).val(''); event.preventDefault(); -} +}; /** * Remove a user from the selected user list @@ -75,7 +75,7 @@ elgg.userpicker.removeUser = function(event) { item.remove(); event.preventDefault(); -} +}; /** * Render the list item for insertion into the selected user list @@ -96,7 +96,7 @@ elgg.userpicker.viewUser = function(info) { html += " Date: Sun, 6 Nov 2011 17:51:59 -0500 Subject: removed uses of CSS class .right from plugins --- mod/embed/views/default/js/embed/embed.php | 3 +-- mod/likes/views/default/annotation/likes.php | 2 +- mod/messages/views/default/object/messages.php | 2 +- mod/thewire/views/default/thewire/profile_status.php | 2 +- .../views/default/forms/twitter_api/interstitial_settings.php | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) (limited to 'mod/embed/views') diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 8e543ac37..8a8f0290c 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -41,10 +41,9 @@ elgg.embed.insert = function(event) { - $.fancybox.close(); event.preventDefault(); diff --git a/mod/likes/views/default/annotation/likes.php b/mod/likes/views/default/annotation/likes.php index 314d0790d..d41522fc4 100644 --- a/mod/likes/views/default/annotation/likes.php +++ b/mod/likes/views/default/annotation/likes.php @@ -30,7 +30,7 @@ $friendlytime = elgg_view_friendly_time($like->time_created); if ($like->canEdit()) { $delete_button = elgg_view("output/confirmlink",array( 'href' => "action/likes/delete?annotation_id={$like->id}", - 'text' => "", + 'text' => "", 'confirm' => elgg_echo('deleteconfirm'), 'encode_text' => false, )); diff --git a/mod/messages/views/default/object/messages.php b/mod/messages/views/default/object/messages.php index e8e745e94..b12f98522 100644 --- a/mod/messages/views/default/object/messages.php +++ b/mod/messages/views/default/object/messages.php @@ -66,7 +66,7 @@ $subject_info .= elgg_view('output/url', array( $delete_link = elgg_view("output/confirmlink", array( 'href' => "action/messages/delete?guid=" . $message->getGUID(), - 'text' => "", + 'text' => "", 'confirm' => elgg_echo('deleteconfirm'), 'encode_text' => false, )); diff --git a/mod/thewire/views/default/thewire/profile_status.php b/mod/thewire/views/default/thewire/profile_status.php index ab20b5341..b5d9dbd80 100644 --- a/mod/thewire/views/default/thewire/profile_status.php +++ b/mod/thewire/views/default/thewire/profile_status.php @@ -27,7 +27,7 @@ if ($latest_wire && count($latest_wire) > 0) { $button = elgg_view('output/url', array( 'text' => elgg_echo('thewire:update'), 'href' => $url_to_wire, - 'class' => 'elgg-button elgg-button-action right', + 'class' => 'elgg-button elgg-button-action float-alt', 'is_trusted' => true, )); } diff --git a/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php index 2592013c6..cad2be345 100644 --- a/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php +++ b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php @@ -55,7 +55,7 @@ echo elgg_view('input/submit', array( )); echo elgg_view('output/url', array( - 'class' => 'right', + 'class' => 'float-alt', 'text' => elgg_echo('twitter_api:interstitial:no_thanks'), 'href' => '/', 'is_trusted' => true, -- cgit v1.2.3