From d82ed5d1b4a3af4d0a4782b809837e3b22d1211d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 15:30:23 +0100 Subject: [PATCH 01/15] Continued with code convention: - added more curly braces - added space betweent if/foreach and brace - added spaces for beautification - converted some " to ' (mixed usage) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/Contact.php | 11 ++- include/acl_selectors.php | 148 ++++++++++++++++++++------------------ mod/fbrowser.php | 31 ++++---- mod/ostatus_subscribe.php | 17 +++-- 4 files changed, 111 insertions(+), 96 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 5cf40a9f03..b1f63cbdfd 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -85,11 +85,12 @@ function contact_remove($id) { function terminate_friendship($user,$self,$contact) { + /// @TODO Get rid of this, include/datetime.php should care about by itself $a = get_app(); require_once('include/datetime.php'); - if($contact['network'] === NETWORK_OSTATUS) { + if ($contact['network'] === NETWORK_OSTATUS) { require_once('include/ostatus.php'); @@ -99,16 +100,14 @@ function terminate_friendship($user,$self,$contact) { $item['follow'] = $contact["url"]; $slap = ostatus::salmon($item, $user); - if((x($contact,'notify')) && (strlen($contact['notify']))) { + if ((x($contact,'notify')) && (strlen($contact['notify']))) { require_once('include/salmon.php'); slapper($user,$contact['notify'],$slap); } - } - elseif($contact['network'] === NETWORK_DIASPORA) { + } elseif ($contact['network'] === NETWORK_DIASPORA) { require_once('include/diaspora.php'); Diaspora::send_unshare($user,$contact); - } - elseif($contact['network'] === NETWORK_DFRN) { + } elseif ($contact['network'] === NETWORK_DFRN) { require_once('include/dfrn.php'); dfrn::deliver($user,$contact,'placeholder', 1); } diff --git a/include/acl_selectors.php b/include/acl_selectors.php index dc86ba0345..a207753797 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -65,20 +65,24 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $exclude = false; $size = 4; - if(is_array($options)) { - if(x($options,'size')) + if (is_array($options)) { + if (x($options,'size')) $size = $options['size']; - if(x($options,'mutual_friends')) + if (x($options,'mutual_friends')) { $mutual = true; - if(x($options,'single')) + } + if (x($options,'single')) { $single = true; - if(x($options,'multiple')) + } + if (x($options,'multiple')) { $single = false; - if(x($options,'exclude')) + } + if (x($options,'exclude')) { $exclude = $options['exclude']; + } - if(x($options,'networks')) { + if (x($options,'networks')) { switch($options['networks']) { case 'DFRN_ONLY': $networks = array(NETWORK_DFRN); @@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { if (dbm::is_result($r)) { foreach ($r as $rr) { - if((is_array($preselected)) && in_array($rr['id'], $preselected)) + if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; - else + } else { $selected = ''; + } $trimmed = mb_substr($rr['name'],0,20); @@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p if ($privmail) { $trimmed = GetProfileUsername($rr['url'], $rr['name'], false); - } - else { + } else { $trimmed = mb_substr($rr['name'],0,20); } @@ -260,16 +264,22 @@ function fixacl(&$item) { function prune_deadguys($arr) { - if(! $arr) + if (! $arr) { return $arr; + } + $str = dbesc(implode(',',$arr)); + $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); + if ($r) { $ret = array(); - foreach($r as $rr) + foreach ($r as $rr) { $ret[] = intval($rr['id']); + } return $ret; } + return array(); } @@ -545,35 +555,33 @@ function acl_lookup(&$a, $out_type = 'json') { dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA) ); - } - elseif($type == 'a') { + } elseif ($type == 'a') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra2 ORDER BY `name` ASC ", intval(local_user()) ); - } - elseif($type == 'x') { + } elseif ($type == 'x') { // autocomplete for global contact search (e.g. navbar search) $r = navbar_complete($a); $contacts = array(); if ($r) { - foreach($r as $g) { + foreach ($r as $g) { $contacts[] = array( - "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), - "name" => $g['name'], - "nick" => (x($g['addr']) ? $g['addr'] : $g['url']), - "network" => $g['network'], - "link" => $g['url'], - "forum" => (x($g['community']) ? 1 : 0), + 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), + 'name' => $g['name'], + 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']), + 'network' => $g['network'], + 'link' => $g['url'], + 'forum' => (x($g['community']) ? 1 : 0), ); } } $o = array( 'start' => $start, - 'count' => $count, - 'items' => $contacts, + 'count' => $count, + 'items' => $contacts, ); echo json_encode($o); killme(); @@ -583,16 +591,16 @@ function acl_lookup(&$a, $out_type = 'json') { if (dbm::is_result($r)) { - foreach($r as $g){ + foreach ($r as $g){ $contacts[] = array( - "type" => "c", - "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($g['name']), - "id" => intval($g['id']), - "network" => $g['network'], - "link" => $g['url'], - "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), - "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), + 'type' => 'c', + 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($g['name']), + 'id' => intval($g['id']), + 'network' => $g['network'], + 'link' => $g['url'], + 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), + 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), ); } } @@ -618,7 +626,7 @@ function acl_lookup(&$a, $out_type = 'json') { implode("','", $known_contacts) ); if (dbm::is_result($r)){ - foreach($r as $row) { + foreach ($r as $row) { // nickname.. $up = parse_url($row['author-link']); $nick = explode("/",$up['path']); @@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') { $nick .= "@".$up['host']; // /nickname $unknow_contacts[] = array( - "type" => "c", - "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), - "name" => htmlentities($row['author-name']), - "id" => '', - "network" => "unknown", - "link" => $row['author-link'], - "nick" => htmlentities($nick), - "forum" => false + 'type' => 'c', + 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), + 'name' => htmlentities($row['author-name']), + 'id' => '', + 'network' => 'unknown', + 'link' => $row['author-link'], + 'nick' => htmlentities($nick), + 'forum' => false ); } } @@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') { } $results = array( - "tot" => $tot, - "start" => $start, - "count" => $count, - "groups" => $groups, - "contacts" => $contacts, - "items" => $items, - "type" => $type, - "search" => $search, + 'tot' => $tot, + 'start' => $start, + 'count' => $count, + 'groups' => $groups, + 'contacts' => $contacts, + 'items' => $items, + 'type' => $type, + 'search' => $search, ); call_hooks('acl_lookup_end', $results); if($out_type === 'html') { $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'groups' => $results["groups"], - 'contacts' => $results["contacts"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'groups' => $results['groups'], + 'contacts' => $results['contacts'], ); return $o; } $o = array( - 'tot' => $results["tot"], - 'start' => $results["start"], - 'count' => $results["count"], - 'items' => $results["items"], + 'tot' => $results['tot'], + 'start' => $results['start'], + 'count' => $results['count'], + 'items' => $results['items'], ); echo json_encode($o); @@ -687,7 +695,7 @@ function navbar_complete(&$a) { // logger('navbar_complete'); - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } @@ -698,28 +706,32 @@ function navbar_complete(&$a) { $mode = $_REQUEST['smode']; // don't search if search term has less than 2 characters - if(! $search || mb_strlen($search) < 2) + if (! $search || mb_strlen($search) < 2) { return array(); + } - if(substr($search,0,1) === '@') + if (substr($search,0,1) === '@') { $search = substr($search,1); + } - if($localsearch) { + if ($localsearch) { $x = DirSearch::global_search_by_name($search, $mode); return $x; } - if(! $localsearch) { + if (! $localsearch) { $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); - if($x['success']) { + if ($x['success']) { $t = 0; $j = json_decode($x['body'],true); - if($j && $j['results']) { + if ($j && $j['results']) { return $j['results']; } } } + + /// @TODO Not needed here? return; } diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 6af97368fb..9c1d43cd8b 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -94,19 +94,19 @@ function fbrowser_content($a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'image', - '$baseurl' => App::get_baseurl(), - '$path' => $path, - '$folders' => $albums, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'image', + '$baseurl' => App::get_baseurl(), + '$path' => $path, + '$folders' => $albums, + '$files' => $files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); break; case "file": - if ($a->argc==2){ + if ($a->argc==2) { $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ", intval(local_user()) ); @@ -116,10 +116,9 @@ function fbrowser_content($a){ list($m1,$m2) = explode("/",$rr['filetype']); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); - if($a->theme['template_engine'] === 'internal') { + if ($a->theme['template_engine'] === 'internal') { $filename_e = template_escape($rr['filename']); - } - else { + } else { $filename_e = $rr['filename']; } @@ -130,12 +129,12 @@ function fbrowser_content($a){ $tpl = get_markup_template($template_file); $o = replace_macros($tpl, array( - '$type' => 'file', - '$baseurl' => App::get_baseurl(), - '$path' => array( array( "", t("Files")) ), - '$folders' => false, - '$files' =>$files, - '$cancel' => t('Cancel'), + '$type' => 'file', + '$baseurl' => App::get_baseurl(), + '$path' => array( array( "", t("Files")) ), + '$folders' => false, + '$files' =>$files, + '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname'], )); diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index 963f436939..04c8d7bde7 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -21,21 +21,24 @@ function ostatus_subscribe_content(&$a) { if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { - if ($_REQUEST["url"] == "") + if ($_REQUEST["url"] == "") { return $o.t("No contact provided."); + } $contact = probe_url($_REQUEST["url"]); - if (!$contact) + if (!$contact) { return $o.t("Couldn't fetch information for contact."); + } $api = $contact["baseurl"]."/api/"; // Fetching friends $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]); - if (!$data["success"]) + if (!$data["success"]) { return $o.t("Couldn't fetch friends for contact."); + } set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); } @@ -61,12 +64,14 @@ function ostatus_subscribe_content(&$a) { $data = probe_url($url); if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid,$url,true); - if ($result["success"]) + if ($result["success"]) { $o .= " - ".t("success"); - else + } else { $o .= " - ".t("failed"); - } else + } + } else { $o .= " - ".t("ignored"); + } $o .= "

"; From 2325d81048a4f4eeb90d08da6066cf939e15d3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:50:40 +0100 Subject: [PATCH 02/15] Code style changed: - added more curly braces - made SQL keywords all-uppercase - added spaces between if/foreach and brace - // Is for single-line comments *only*, please don't abuse it for multiple line comments, use /* */ instead and a asterisk in front of every line. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/dbstructure.php | 91 ++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index be1158eabe..50c2856ab6 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -26,7 +26,6 @@ function update_fail($update_id, $error_message){ } // every admin could had different language - foreach ($adminlist as $admin) { $lang = (($admin['language'])?$admin['language']:'en'); push_lang($lang); @@ -83,8 +82,9 @@ function table_structure($table) { if (dbm::is_result($indexes)) foreach ($indexes AS $index) { - if ($index["Index_type"] == "FULLTEXT") + if ($index["Index_type"] == "FULLTEXT") { continue; + } if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { $indexdata[$index["Key_name"]] = array('UNIQUE'); @@ -95,26 +95,31 @@ function table_structure($table) { // To avoid the need to add this to every index definition we just ignore it here. // Exception are primary indexes // Since there are some combindex primary indexes we use the limit of 180 here. - if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) + if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) { $column .= "(".$index["Sub_part"].")"; + } $indexdata[$index["Key_name"]][] = $column; } if (dbm::is_result($structures)) { - foreach($structures AS $field) { + foreach ($structures AS $field) { $fielddata[$field["Field"]]["type"] = $field["Type"]; - if ($field["Null"] == "NO") + if ($field["Null"] == "NO") { $fielddata[$field["Field"]]["not null"] = true; + } - if (isset($field["Default"])) + if (isset($field["Default"])) { $fielddata[$field["Field"]]["default"] = $field["Default"]; + } - if ($field["Extra"] != "") + if ($field["Extra"] != "") { $fielddata[$field["Field"]]["extra"] = $field["Extra"]; + } - if ($field["Key"] == "PRI") + if ($field["Key"] == "PRI") { $fielddata[$field["Field"]]["primary"] = true; + } } } return(array("fields"=>$fielddata, "indexes"=>$indexdata)); @@ -138,13 +143,15 @@ function print_structure($database, $charset) { function update_structure($verbose, $action, $tables=null, $definition=null) { global $a, $db; - if ($action) + if ($action) { set_config('system', 'maintenance', 1); + } - if (isset($a->config["system"]["db_charset"])) + if (isset($a->config["system"]["db_charset"])) { $charset = $a->config["system"]["db_charset"]; - else + } else { $charset = "utf8"; + } $errors = false; @@ -153,8 +160,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { // Get the current structure $database = array(); - if (is_null($tables)) - $tables = q("show tables"); + if (is_null($tables)) { + $tables = q("SHOW TABLES"); + } foreach ($tables AS $table) { $table = current($table); @@ -164,21 +172,24 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } // Get the definition - if (is_null($definition)) + if (is_null($definition)) { $definition = db_definition($charset); + } // Ensure index conversion to unique removes duplicates $sql_config = "SET session old_alter_table=1;"; - if ($verbose) + if ($verbose) { echo $sql_config."\n"; - if ($action) - @$db->q($sql_config); + } + if ($action) { + $db->q($sql_config); + } // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements if ((version_compare($db->server_info(), '5.7.4') >= 0) AND !(strpos($db->server_info(), 'MariaDB') !== false)) { $ignore = ''; - }else { + } else { $ignore = ' IGNORE'; } @@ -193,10 +204,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } $is_new_table = True; } else { - // Drop the index if it isn't present in the definition - // or the definition differ from current status - // and index name doesn't start with "local_" - foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) { + /* + * Drop the index if it isn't present in the definition + * or the definition differ from current status + * and index name doesn't start with "local_" + */ + foreach ($database[$name]["indexes"] as $indexname => $fieldnames) { $current_index_definition = implode(",",$fieldnames); if (isset($structure["indexes"][$indexname])) { $new_index_definition = implode(",",$structure["indexes"][$indexname]); @@ -205,39 +218,44 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { } if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') { $sql2=db_drop_index($indexname); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { $sql2=db_add_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } else { // Compare the field definition $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $new_field_definition = implode(",",$parameters); if ($current_field_definition != $new_field_definition) { $sql2=db_modify_table_field($fieldname, $parameters); - if ($sql3 == "") + if ($sql3 == "") { $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else + } else { $sql3 .= ", ".$sql2; + } } } } } - // Create the index if the index don't exists in database - // or the definition differ from the current status. - // Don't create keys if table is new + /* + * Create the index if the index don't exists in database + * or the definition differ from the current status. + * Don't create keys if table is new + */ if (!$is_new_table) { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { @@ -367,10 +385,11 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { if ($names != "") $names .= ","; - if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) + if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")"; - else + } else { $names .= "`".dbesc($fieldname)."`"; + } } if ($indexname == "PRIMARY") { @@ -383,8 +402,9 @@ function db_create_index($indexname, $fieldnames, $method="ADD") { } function db_index_suffix($charset, $reduce = 0) { - if ($charset != "utf8mb4") + if ($charset != "utf8mb4") { return ""; + } // On utf8mb4 indexes can only have a length of 191 $indexlength = 191 - $reduce; @@ -1573,9 +1593,6 @@ function dbstructure_run(&$argv, &$argc) { echo "dumpsql dump database schema\n"; return; - - - } if (array_search(__file__,get_included_files())===0){ From 9c81b4948eeb22a51b28dbe67896b7e019809544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 16:58:50 +0100 Subject: [PATCH 03/15] Coding convention applied: - added curly braces - added space between if/foreach and brace - avoided 2 return statements (true/false) by replacing them with just one - added TODO for applying above to all findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/items.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index e91c7088ab..10afc28c0e 100644 --- a/include/items.php +++ b/include/items.php @@ -1257,8 +1257,9 @@ function tag_deliver($uid,$item_id) { $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1", intval($u[0]['uid']) ); - if (! count($c)) + if (! count($c)) { return; + } // also reset all the privacy bits to the forum default permissions @@ -1266,8 +1267,8 @@ function tag_deliver($uid,$item_id) { $forum_mode = (($prvgroup) ? 2 : 1); - q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', - `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d", + q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', + `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d", intval($forum_mode), dbesc($c[0]['name']), dbesc($c[0]['url']), @@ -1318,7 +1319,7 @@ function tgroup_check($uid,$item) { $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); if ($cnt) { - foreach($matches as $mtch) { + foreach ($matches as $mtch) { if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) { $mention = true; logger('tgroup_check: mention found: ' . $mtch[2]); @@ -1326,13 +1327,12 @@ function tgroup_check($uid,$item) { } } - if (! $mention) + if (! $mention) { return false; + } - if ((! $community_page) && (! $prvgroup)) - return false; - - return true; + /// @TODO Combines both return statements into one + return (($community_page) || ($prvgroup)); } /* @@ -1344,15 +1344,16 @@ function tgroup_check($uid,$item) { assumes the update has been seen before and should be ignored. */ function edited_timestamp_is_newer($existing, $update) { - if (!x($existing,'edited') || !$existing['edited']) { - return true; - } - if (!x($update,'edited') || !$update['edited']) { - return false; - } - $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); - $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); - return (strcmp($existing_edited, $update_edited) < 0); + if (!x($existing,'edited') || !$existing['edited']) { + return true; + } + if (!x($update,'edited') || !$update['edited']) { + return false; + } + + $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']); + $update_edited = datetime_convert('UTC', 'UTC', $update['edited']); + return (strcmp($existing_edited, $update_edited) < 0); } /** From 31cd3fb33c088573a1b240a2b982c781197bab79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Dec 2016 17:12:34 +0100 Subject: [PATCH 04/15] Coding convention continued: - added curly braces - added spaces between if/foreach and brace - made code block look nicer (spaces added, tabs replaced by space) - added TODO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/common.php | 71 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/mod/common.php b/mod/common.php index 0be8f1d14a..9657ac36d8 100644 --- a/mod/common.php +++ b/mod/common.php @@ -19,23 +19,27 @@ function common_content(&$a) { return; } - if($cmd !== 'loc' && $cmd != 'rem') + if ($cmd !== 'loc' && $cmd != 'rem') { return; + } - if(! $uid) + if (! $uid) { return; + } - if($cmd === 'loc' && $cid) { + if ($cmd === 'loc' && $cid) { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); } else { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid) ); + /// @TODO Handle $c with dbm::is_result() $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array( '$name' => htmlentities($c[0]['name']), @@ -43,8 +47,9 @@ function common_content(&$a) { 'url' => 'contacts/' . $cid )); - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } $a->page['aside'] .= $vcard_widget; } @@ -69,29 +74,29 @@ function common_content(&$a) { } } - - - if($cid == 0 && $zcid == 0) + if ($cid == 0 && $zcid == 0) { return; + } - - if($cid) + if ($cid) { $t = count_common_friends($uid, $cid); - else + } else { $t = count_common_friends_zcid($uid, $zcid); + } - if(count($t)) + if (count($t)) { $a->set_pager_total($t); - else { + } else { notice( t('No contacts in common.') . EOL); return $o; } - if($cid) + if ($cid) { $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); - else + } else { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); + } if (! dbm::is_result($r)) { @@ -105,39 +110,41 @@ function common_content(&$a) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); - // $rr[id] is needed to use contact_photo_menu() - $rr[id] = $rr[cid]; + // $rr['id'] is needed to use contact_photo_menu() + /// @TODO Adding '/" here avoids E_NOTICE on missing constants + $rr['id'] = $rr['cid']; $photo_menu = ''; $photo_menu = contact_photo_menu($rr); $entry = array( - 'url' => $rr['url'], - 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), - 'name' => $contact_details['name'], - 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), - 'img_hover' => htmlentities($contact_details['name']), - 'details' => $contact_details['location'], - 'tags' => $contact_details['keywords'], - 'about' => $contact_details['about'], - 'account_type' => account_type($contact_details), - 'network' => network_to_name($contact_details['network'], $contact_details['url']), - 'photo_menu' => $photo_menu, - 'id' => ++$id, + 'url' => $rr['url'], + 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), + 'name' => $contact_details['name'], + 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB), + 'img_hover' => htmlentities($contact_details['name']), + 'details' => $contact_details['location'], + 'tags' => $contact_details['keywords'], + 'about' => $contact_details['about'], + 'account_type' => account_type($contact_details), + 'network' => network_to_name($contact_details['network'], $contact_details['url']), + 'photo_menu' => $photo_menu, + 'id' => ++$id, ); $entries[] = $entry; } - if($cmd === 'loc' && $cid && $uid == local_user()) { + if ($cmd === 'loc' && $cid && $uid == local_user()) { $tab_str = contacts_tab($a, $cid, 4); - } else + } else { $title = t('Common Friends'); + } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl,array( - '$title' => $title, - '$tab_str' => $tab_str, + '$title' => $title, + '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a), )); From e95337e9ae04f0535877ea3dc550eec74a21bb94 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 23 Dec 2016 18:31:42 +0100 Subject: [PATCH 05/15] correct doxygen @todo --- include/Probe.php | 2 +- include/socgraph.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Probe.php b/include/Probe.php index 5c2ba86ccd..6145daaaae 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -324,7 +324,7 @@ class Probe { !isset($parts["path"])) return false; - // todo: Ports? + /// @todo: Ports? $host = $parts["host"]; if ($host == 'twitter.com') diff --git a/include/socgraph.php b/include/socgraph.php index 135d759bfd..64f78b4585 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -1187,7 +1187,7 @@ function update_suggestions() { $done = array(); - /// TODO Check if it is really neccessary to poll the own server + /// @TODO Check if it is really neccessary to poll the own server poco_load(0,0,0,App::get_baseurl() . '/poco'); $done[] = App::get_baseurl() . '/poco'; From 3677467cefc505a823f643de5d73d28294d485e3 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 24 Dec 2016 02:27:17 +0100 Subject: [PATCH 06/15] update perfect-scrollbar to version 0.6.15 --- library/perfect-scrollbar/README.md | 134 +++-- .../perfect-scrollbar/perfect-scrollbar.css | 116 ++-- .../perfect-scrollbar.jquery.js | 539 +++++++++--------- .../perfect-scrollbar.jquery.min.js | 2 + .../perfect-scrollbar.min.css | 4 +- view/templates/head.tpl | 2 +- view/theme/frio/templates/head.tpl | 2 +- 7 files changed, 424 insertions(+), 375 deletions(-) create mode 100644 library/perfect-scrollbar/perfect-scrollbar.jquery.min.js diff --git a/library/perfect-scrollbar/README.md b/library/perfect-scrollbar/README.md index b0e732827d..b05f5c2956 100644 --- a/library/perfect-scrollbar/README.md +++ b/library/perfect-scrollbar/README.md @@ -52,16 +52,26 @@ It's cool, isn't it? ## Install +#### NPM + The best way to install and use perfect-scrollbar is with NPM. -It's registered on [npm](https://www.npmjs.org/package/perfect-scrollbar) as `perfect-scrollbar`. +It's registered on [npm](https://www.npmjs.com/package/perfect-scrollbar) as `perfect-scrollbar`. ``` $ npm install perfect-scrollbar ``` +#### Rails + +In the case you would like to have perfect-scrollbar in your Rails application, there is the [perfect-scrollbar-rails gem](https://github.com/YourCursus/perfect-scrollbar-rails). + +#### Manually + You can download the latest stable version with download links [here](http://noraesae.github.io/perfect-scrollbar/). You also can find all releases on [Releases](https://github.com/noraesae/perfect-scrollbar/releases). +#### From sources + If you want to use the development version of the plugin, use the source files which are not minified. They're in the `src` directory. The development version may be unstable, but some known bugs may @@ -74,6 +84,7 @@ $ npm install $ gulp # will lint and build the source code. ``` +#### Bower There is a Bower package for perfect-scrollbar as well. It is managed under the [perfect-scrollbar-bower](https://github.com/noraesae/perfect-scrollbar-bower) @@ -83,26 +94,38 @@ repository. The plugin is registered as `perfect-scrollbar`. $ bower install perfect-scrollbar ``` +#### CDNs -You can also load it from [cdnjs](http://cdnjs.com/). -It is registered as [`jquery.perfect-scrollbar`](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar). +* [cdnjs](http://www.cdnjs.com/libraries/jquery.perfect-scrollbar) +* [JSDelivr](https://www.jsdelivr.com/projects/perfect-scrollbar) -## Requirements +#### JSFiddle -To make this plugin *perfect*, some requirements were unavoidable. -But, they're all very trivial and there is nothing to worry about. +You can fork the following JSFiddles for testing and experimenting purposes: + +* [Perfect Scrollbar](https://jsfiddle.net/DanielApt/xv0rrxv3/) +* [Perfect Scrollbar (jQuery)](https://jsfiddle.net/DanielApt/gbfLazpx/) + +## Before using perfect-scrollbar The following requirements should meet. * the container must have a 'position' css style. +* the container must be a normal container element. + * PS may not work well in `body`, `textarea`, `iframe` or flexbox. The following requirements are included in the basic CSS, but please keep in mind when you'd like to change the CSS files. -* the container must have an 'overflow:hidden' css style. +* the container must have an 'overflow: hidden' css style. * the scrollbar's position must be 'absolute'. * the scrollbar-x must have a 'bottom' css style, and the scrollbar-y must have a 'right' css style. + +Please keep in mind that perfect-scrollbar won't completely emulate native +scrolls. Scroll hooking is generally considered as bad practice, and +perfect-scrollbar should be used with care. Unless custom scroll is really needed, +please consider using native scrolls. ## How to use @@ -155,7 +178,7 @@ If the size of your container or content changes, call `update`. Ps.update(container); ``` -If you want to destory the scrollbar, use `destroy`. +If you want to destroy the scrollbar, use `destroy`. ```javascript Ps.destroy(container); @@ -238,12 +261,12 @@ define([ 'perfectScrollbarJquery' ], function (angular) { - var myApp = angular.module('myApp', []) - .run(function() { + var app = angular.module('myApp', []); + app.run(function () { window.Ps = require('perfectScrollbar'); require('perfectScrollbarJQuery'); - }) - return myApp; + }); + return app; }); ``` @@ -256,7 +279,7 @@ Ps.initialize(container); Ps.update(container); // or by jQuery: -var imgLoader = $("#imgLoader") +var imgLoader = $('#imgLoader') imgLoader.perfectScrollbar(); ``` @@ -264,57 +287,80 @@ imgLoader.perfectScrollbar(); perfect-scrollbar supports optional parameters. +### handlers +It is a list of handlers to use to scroll the element. +**Default**: `['click-rail', 'drag-scrollbar', 'keyboard', 'wheel', 'touch']` +**Disabled by default**: `'selection'` + ### wheelSpeed The scroll speed applied to mousewheel event. -**Default: 1** +**Default**: `1` ### wheelPropagation If this option is true, when the scroll reaches the end of the side, mousewheel event will be propagated to parent element. -**Default: false** +**Default**: `false` ### swipePropagation If this option is true, when the scroll reaches the end of the side, touch scrolling will be propagated to parent element. -**Default: true** +**Default**: `true` ### minScrollbarLength When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels. -**Default: null** +**Default**: `null` ### maxScrollbarLength When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels. -**Default: null** +**Default**: `null` ### useBothWheelAxes When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar. -**Default: false** - -### useKeyboard -When set to true, the scroll works with arrow keys on the keyboard. The element is scrolled only when the mouse cursor hovers the element. -**Default: true** +**Default**: `false` ### suppressScrollX When set to true, the scroll bar in X axis will not be available, regardless of the content width. -**Default: false** +**Default**: `false` ### suppressScrollY When set to true, the scroll bar in Y axis will not be available, regardless of the content height. -**Default: false** +**Default**: `false` ### scrollXMarginOffset The number of pixels the content width can surpass the container width without enabling the X axis scroll bar. Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels. -**Default: 0** +**Default**: `0` ### scrollYMarginOffset The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar. Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels. -**Default: 0** +**Default**: `0` -### stopPropagationOnClick -When set to false, when clicking on a rail, the click event will be allowed to propagate. -**Default: true** +### theme +A string. It's a class name added to the container element. The class name is prepended with `ps-theme-`. So default theme class name is `ps-theme-default`. In order to create custom themes with scss use `ps-container($theme)` mixin, where `$theme` is a scss map. +**Default**: `'default'` + +**Example 1:** + +Add `theme` parameter: +```javascript +Ps.initialize(container, { + theme: 'my-theme-name' +}); +``` +Create a class name prefixed with `.ps-theme-`. Include `ps-container()` mixin. It's recommended to use `map-merge()` to extend `$ps-theme-default` map with your custom styles. +```scss +.ps-theme-my-theme-name { + @include ps-container(map-merge($ps-theme-default, ( + border-radius: 0, + scrollbar-x-rail-height: 20px, + scrollbar-x-height: 20px, + scrollbar-y-rail-width: 20px, + scrollbar-y-width: 20px + ))); +} +``` + +**Example 2:** + +Alternatively, if you don't want to create your own themes, but only modify the default one, you could simply overwrite `$ps-*` variables with your own values. In this case `theme` parameter is not required when calling `.initialize()` method. Remember do define your own variables before the `theme.scss` file is imported. -### useSelectionScroll -When set to true, you can scroll the container by selecting text and move the cursor. -**Default: false** ## Events @@ -363,24 +409,20 @@ $(document).on('ps-scroll-x', function () { }) ``` -## Contribution +## Tips -#### Please read [Contributing](https://github.com/noraesae/perfect-scrollbar/wiki/Contributing) in the wiki before making any contribution. +### Scrolling children inside perfect-scrollbar - -I *really* welcome contributions! Please feel free to fork and issue pull requests when... - -* You have a very nice idea to improve this plugin! -* You found a bug! -* You're good at English and can help my bad English! - -For IE problems, please refer to [IE Support](https://github.com/noraesae/perfect-scrollbar#ie-support). +You can natively scroll children inside `perfect-scrollbar` with the mouse-wheel. Scrolling automatically works if +the child is a `textarea`. All other elements need to have the `ps-child` class. This is demonstrated in [`/examples/children-native-scroll.html`](examples/children-native-scroll.html) ## IE Support -The plugin would work in IEs >= IE9 (not well, though). +The plugin is designed to work in modern browsers, including the very latest +version of IE and Edge. Specifically, it should work in IEs >= IE10. If there +is any issue in the browsers, please [file it](https://github.com/noraesae/perfect-scrollbar/issues). -**The patches to fix problems in IE<=8 won't be accepted.** +**The patches to fix problems in IE<=9 won't be accepted.** When old IEs should be supported, please fork the project and make patches personally. @@ -396,7 +438,7 @@ For common problems there is a ## License -The MIT License (MIT) Copyright (c) 2015 Hyunje Alex Jun and other contributors. +The MIT License (MIT) Copyright (c) 2016 Hyunje Alex Jun and other contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/library/perfect-scrollbar/perfect-scrollbar.css b/library/perfect-scrollbar/perfect-scrollbar.css index 354705dd57..735219ce76 100644 --- a/library/perfect-scrollbar/perfect-scrollbar.css +++ b/library/perfect-scrollbar/perfect-scrollbar.css @@ -1,7 +1,7 @@ -/* perfect-scrollbar v0.6.10 */ +/* perfect-scrollbar v0.6.15 */ .ps-container { - -ms-touch-action: none; - touch-action: none; + -ms-touch-action: auto; + touch-action: auto; overflow: hidden !important; -ms-overflow-style: none; } @supports (-ms-overflow-style: none) { @@ -14,88 +14,90 @@ .ps-container.ps-active-y > .ps-scrollbar-y-rail { display: block; background-color: transparent; } - .ps-container.ps-in-scrolling { - pointer-events: none; } - .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { - background-color: #eee; - opacity: 0.9; } - .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { - background-color: #999; } - .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { - background-color: #eee; - opacity: 0.9; } - .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { - background-color: #999; } + .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #999; + height: 11px; } + .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #999; + width: 11px; } .ps-container > .ps-scrollbar-x-rail { display: none; position: absolute; /* please don't change 'position' */ - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; opacity: 0; -webkit-transition: background-color .2s linear, opacity .2s linear; - -moz-transition: background-color .2s linear, opacity .2s linear; -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; transition: background-color .2s linear, opacity .2s linear; - bottom: 3px; + bottom: 0px; /* there must be 'bottom' for ps-scrollbar-x-rail */ - height: 8px; } + height: 15px; } .ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x { position: absolute; /* please don't change 'position' */ background-color: #aaa; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - -webkit-transition: background-color .2s linear; - -moz-transition: background-color .2s linear; - -o-transition: background-color .2s linear; - transition: background-color .2s linear; - bottom: 0; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + bottom: 2px; /* there must be 'bottom' for ps-scrollbar-x */ - height: 8px; } + height: 6px; } + .ps-container > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x, .ps-container > .ps-scrollbar-x-rail:active > .ps-scrollbar-x { + height: 11px; } .ps-container > .ps-scrollbar-y-rail { display: none; position: absolute; /* please don't change 'position' */ - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; opacity: 0; -webkit-transition: background-color .2s linear, opacity .2s linear; - -moz-transition: background-color .2s linear, opacity .2s linear; -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; transition: background-color .2s linear, opacity .2s linear; - right: 3px; + right: 0; /* there must be 'right' for ps-scrollbar-y-rail */ - width: 8px; } + width: 15px; } .ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y { position: absolute; /* please don't change 'position' */ background-color: #aaa; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - -webkit-transition: background-color .2s linear; - -moz-transition: background-color .2s linear; - -o-transition: background-color .2s linear; - transition: background-color .2s linear; - right: 0; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + right: 2px; /* there must be 'right' for ps-scrollbar-y */ - width: 8px; } - .ps-container:hover.ps-in-scrolling { - pointer-events: none; } - .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { - background-color: #eee; - opacity: 0.9; } - .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { - background-color: #999; } - .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { - background-color: #eee; - opacity: 0.9; } - .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { - background-color: #999; } + width: 6px; } + .ps-container > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y, .ps-container > .ps-scrollbar-y-rail:active > .ps-scrollbar-y { + width: 11px; } + .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #999; + height: 11px; } + .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: #eee; + opacity: 0.9; } + .ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #999; + width: 11px; } .ps-container:hover > .ps-scrollbar-x-rail, .ps-container:hover > .ps-scrollbar-y-rail { opacity: 0.6; } diff --git a/library/perfect-scrollbar/perfect-scrollbar.jquery.js b/library/perfect-scrollbar/perfect-scrollbar.jquery.js index d94ed91bcd..5872325b73 100644 --- a/library/perfect-scrollbar/perfect-scrollbar.jquery.js +++ b/library/perfect-scrollbar/perfect-scrollbar.jquery.js @@ -1,16 +1,9 @@ -/* perfect-scrollbar v0.6.10 - * - * Copyright (c) 2015 Hyunje Alex Jun and other contributors - * Licensed under the MIT License - * - * Source: https://github.com/noraesae/perfect-scrollbar - */ - +/* perfect-scrollbar v0.6.15 */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o i.scrollbarYTop ? 1 : -1; - if (positionRatio < 0) { - positionRatio = 0; - } else if (positionRatio > 1) { - positionRatio = 1; - } - - updateScroll(element, 'top', (i.contentHeight - i.containerHeight) * positionRatio); + updateScroll(element, 'top', element.scrollTop + direction * i.containerHeight); updateGeometry(element); e.stopPropagation(); }); - if (i.settings.stopPropagationOnClick) { - i.event.bind(i.scrollbarX, 'click', stopPropagation); - } + i.event.bind(i.scrollbarX, 'click', stopPropagation); i.event.bind(i.scrollbarXRail, 'click', function (e) { - var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2); - var positionLeft = i.railXRatio * (e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength); - var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth); - var positionRatio = positionLeft / maxPositionLeft; + var positionLeft = e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left; + var direction = positionLeft > i.scrollbarXLeft ? 1 : -1; - if (positionRatio < 0) { - positionRatio = 0; - } else if (positionRatio > 1) { - positionRatio = 1; - } - - updateScroll(element, 'left', ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment); + updateScroll(element, 'left', element.scrollLeft + direction * i.containerWidth); updateGeometry(element); e.stopPropagation(); @@ -471,14 +441,14 @@ module.exports = function (element) { bindClickRailHandler(element, i); }; -},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){ +},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){ 'use strict'; -var d = require('../../lib/dom') - , h = require('../../lib/helper') - , instances = require('../instances') - , updateGeometry = require('../update-geometry') - , updateScroll = require('../update-scroll'); +var _ = require('../../lib/helper'); +var dom = require('../../lib/dom'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); +var updateScroll = require('../update-scroll'); function bindMouseScrollXHandler(element, i) { var currentLeft = null; @@ -496,7 +466,7 @@ function bindMouseScrollXHandler(element, i) { i.scrollbarXLeft = newLeft; } - var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment; + var scrollLeft = _.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment; updateScroll(element, 'left', scrollLeft); } @@ -508,14 +478,14 @@ function bindMouseScrollXHandler(element, i) { }; var mouseUpHandler = function () { - h.stopScrolling(element, 'x'); + _.stopScrolling(element, 'x'); i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); }; i.event.bind(i.scrollbarX, 'mousedown', function (e) { currentPageX = e.pageX; - currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio; - h.startScrolling(element, 'x'); + currentLeft = _.toInt(dom.css(i.scrollbarX, 'left')) * i.railXRatio; + _.startScrolling(element, 'x'); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); @@ -541,7 +511,7 @@ function bindMouseScrollYHandler(element, i) { i.scrollbarYTop = newTop; } - var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight))); + var scrollTop = _.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight))); updateScroll(element, 'top', scrollTop); } @@ -553,14 +523,14 @@ function bindMouseScrollYHandler(element, i) { }; var mouseUpHandler = function () { - h.stopScrolling(element, 'y'); + _.stopScrolling(element, 'y'); i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); }; i.event.bind(i.scrollbarY, 'mousedown', function (e) { currentPageY = e.pageY; - currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio; - h.startScrolling(element, 'y'); + currentTop = _.toInt(dom.css(i.scrollbarY, 'top')) * i.railYRatio; + _.startScrolling(element, 'y'); i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); @@ -579,11 +549,11 @@ module.exports = function (element) { },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){ 'use strict'; -var h = require('../../lib/helper') - , d = require('../../lib/dom') - , instances = require('../instances') - , updateGeometry = require('../update-geometry') - , updateScroll = require('../update-scroll'); +var _ = require('../../lib/helper'); +var dom = require('../../lib/dom'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); +var updateScroll = require('../update-scroll'); function bindKeyboardHandler(element, i) { var hovered = false; @@ -619,12 +589,12 @@ function bindKeyboardHandler(element, i) { } i.event.bind(i.ownerDocument, 'keydown', function (e) { - if (e.isDefaultPrevented && e.isDefaultPrevented()) { + if ((e.isDefaultPrevented && e.isDefaultPrevented()) || e.defaultPrevented) { return; } - var focused = d.matches(i.scrollbarX, ':focus') || - d.matches(i.scrollbarY, ':focus'); + var focused = dom.matches(i.scrollbarX, ':focus') || + dom.matches(i.scrollbarY, ':focus'); if (!hovered && !focused) { return; @@ -632,11 +602,15 @@ function bindKeyboardHandler(element, i) { var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement; if (activeElement) { - // go deeper if element is a webcomponent - while (activeElement.shadowRoot) { - activeElement = activeElement.shadowRoot.activeElement; + if (activeElement.tagName === 'IFRAME') { + activeElement = activeElement.contentDocument.activeElement; + } else { + // go deeper if element is a webcomponent + while (activeElement.shadowRoot) { + activeElement = activeElement.shadowRoot.activeElement; + } } - if (h.isEditable(activeElement)) { + if (_.isEditable(activeElement)) { return; } } @@ -646,16 +620,40 @@ function bindKeyboardHandler(element, i) { switch (e.which) { case 37: // left - deltaX = -30; + if (e.metaKey) { + deltaX = -i.contentWidth; + } else if (e.altKey) { + deltaX = -i.containerWidth; + } else { + deltaX = -30; + } break; case 38: // up - deltaY = 30; + if (e.metaKey) { + deltaY = i.contentHeight; + } else if (e.altKey) { + deltaY = i.containerHeight; + } else { + deltaY = 30; + } break; case 39: // right - deltaX = 30; + if (e.metaKey) { + deltaX = i.contentWidth; + } else if (e.altKey) { + deltaX = i.containerWidth; + } else { + deltaX = 30; + } break; case 40: // down - deltaY = -30; + if (e.metaKey) { + deltaY = -i.contentHeight; + } else if (e.altKey) { + deltaY = -i.containerHeight; + } else { + deltaY = -30; + } break; case 33: // page up deltaY = 90; @@ -707,9 +705,9 @@ module.exports = function (element) { },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){ 'use strict'; -var instances = require('../instances') - , updateGeometry = require('../update-geometry') - , updateScroll = require('../update-scroll'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); +var updateScroll = require('../update-scroll'); function bindMouseWheelHandler(element, i) { var shouldPrevent = false; @@ -759,23 +757,30 @@ function bindMouseWheelHandler(element, i) { deltaY = e.wheelDelta; } + if (e.shiftKey) { + // reverse axis with shift key + return [-deltaY, -deltaX]; + } return [deltaX, deltaY]; } - function shouldBeConsumedByTextarea(deltaX, deltaY) { - var hoveredTextarea = element.querySelector('textarea:hover'); - if (hoveredTextarea) { - var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight; + function shouldBeConsumedByChild(deltaX, deltaY) { + var child = element.querySelector('textarea:hover, select[multiple]:hover, .ps-child:hover'); + if (child) { + if (!window.getComputedStyle(child).overflow.match(/(scroll|auto)/)) { + // if not scrollable + return false; + } + + var maxScrollTop = child.scrollHeight - child.clientHeight; if (maxScrollTop > 0) { - if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) && - !(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) { + if (!(child.scrollTop === 0 && deltaY > 0) && !(child.scrollTop === maxScrollTop && deltaY < 0)) { return true; } } - var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth; + var maxScrollLeft = child.scrollLeft - child.clientWidth; if (maxScrollLeft > 0) { - if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) && - !(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) { + if (!(child.scrollLeft === 0 && deltaX < 0) && !(child.scrollLeft === maxScrollLeft && deltaX > 0)) { return true; } } @@ -789,7 +794,7 @@ function bindMouseWheelHandler(element, i) { var deltaX = delta[0]; var deltaY = delta[1]; - if (shouldBeConsumedByTextarea(deltaX, deltaY)) { + if (shouldBeConsumedByChild(deltaX, deltaY)) { return; } @@ -843,8 +848,8 @@ module.exports = function (element) { },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){ 'use strict'; -var instances = require('../instances') - , updateGeometry = require('../update-geometry'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); function bindNativeScrollHandler(element, i) { i.event.bind(element, 'scroll', function () { @@ -860,10 +865,10 @@ module.exports = function (element) { },{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){ 'use strict'; -var h = require('../../lib/helper') - , instances = require('../instances') - , updateGeometry = require('../update-geometry') - , updateScroll = require('../update-scroll'); +var _ = require('../../lib/helper'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); +var updateScroll = require('../update-scroll'); function bindSelectionHandler(element, i) { function getRangeNode() { @@ -897,7 +902,7 @@ function bindSelectionHandler(element, i) { clearInterval(scrollingLoop); scrollingLoop = null; } - h.stopScrolling(element); + _.stopScrolling(element); } var isSelected = false; @@ -915,6 +920,12 @@ function bindSelectionHandler(element, i) { stopScrolling(); } }); + i.event.bind(window, 'keyup', function () { + if (isSelected) { + isSelected = false; + stopScrolling(); + } + }); i.event.bind(window, 'mousemove', function (e) { if (isSelected) { @@ -928,10 +939,10 @@ function bindSelectionHandler(element, i) { if (mousePosition.x < containerGeometry.left + 3) { scrollDiff.left = -5; - h.startScrolling(element, 'x'); + _.startScrolling(element, 'x'); } else if (mousePosition.x > containerGeometry.right - 3) { scrollDiff.left = 5; - h.startScrolling(element, 'x'); + _.startScrolling(element, 'x'); } else { scrollDiff.left = 0; } @@ -942,14 +953,14 @@ function bindSelectionHandler(element, i) { } else { scrollDiff.top = -20; } - h.startScrolling(element, 'y'); + _.startScrolling(element, 'y'); } else if (mousePosition.y > containerGeometry.bottom - 3) { if (mousePosition.y - containerGeometry.bottom + 3 < 5) { scrollDiff.top = 5; } else { scrollDiff.top = 20; } - h.startScrolling(element, 'y'); + _.startScrolling(element, 'y'); } else { scrollDiff.top = 0; } @@ -971,9 +982,10 @@ module.exports = function (element) { },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){ 'use strict'; -var instances = require('../instances') - , updateGeometry = require('../update-geometry') - , updateScroll = require('../update-scroll'); +var _ = require('../../lib/helper'); +var instances = require('../instances'); +var updateGeometry = require('../update-geometry'); +var updateScroll = require('../update-scroll'); function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { function shouldPreventDefault(deltaX, deltaY) { @@ -1058,6 +1070,9 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { } } function touchMove(e) { + if (!inLocalTouch && i.settings.swipePropagation) { + touchStart(e); + } if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) { var touch = getTouch(e); @@ -1095,6 +1110,11 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { return; } + if (!speed.x && !speed.y) { + clearInterval(easingLoop); + return; + } + if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) { clearInterval(easingLoop); return; @@ -1133,27 +1153,33 @@ function bindTouchHandler(element, i, supportsTouch, supportsIePointer) { } } -module.exports = function (element, supportsTouch, supportsIePointer) { +module.exports = function (element) { + if (!_.env.supportsTouch && !_.env.supportsIePointer) { + return; + } + var i = instances.get(element); - bindTouchHandler(element, i, supportsTouch, supportsIePointer); + bindTouchHandler(element, i, _.env.supportsTouch, _.env.supportsIePointer); }; -},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){ +},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){ 'use strict'; -var cls = require('../lib/class') - , h = require('../lib/helper') - , instances = require('./instances') - , updateGeometry = require('./update-geometry'); +var _ = require('../lib/helper'); +var cls = require('../lib/class'); +var instances = require('./instances'); +var updateGeometry = require('./update-geometry'); // Handlers -var clickRailHandler = require('./handler/click-rail') - , dragScrollbarHandler = require('./handler/drag-scrollbar') - , keyboardHandler = require('./handler/keyboard') - , mouseWheelHandler = require('./handler/mouse-wheel') - , nativeScrollHandler = require('./handler/native-scroll') - , selectionHandler = require('./handler/selection') - , touchHandler = require('./handler/touch'); +var handlers = { + 'click-rail': require('./handler/click-rail'), + 'drag-scrollbar': require('./handler/drag-scrollbar'), + 'keyboard': require('./handler/keyboard'), + 'wheel': require('./handler/mouse-wheel'), + 'touch': require('./handler/touch'), + 'selection': require('./handler/selection') +}; +var nativeScrollHandler = require('./handler/native-scroll'); module.exports = function (element, userSettings) { userSettings = typeof userSettings === 'object' ? userSettings : {}; @@ -1163,50 +1189,40 @@ module.exports = function (element, userSettings) { // Create a plugin instance. var i = instances.add(element); - i.settings = h.extend(i.settings, userSettings); + i.settings = _.extend(i.settings, userSettings); cls.add(element, 'ps-theme-' + i.settings.theme); - clickRailHandler(element); - dragScrollbarHandler(element); - mouseWheelHandler(element); + i.settings.handlers.forEach(function (handlerName) { + handlers[handlerName](element); + }); + nativeScrollHandler(element); - if (i.settings.useSelectionScroll) { - selectionHandler(element); - } - - if (h.env.supportsTouch || h.env.supportsIePointer) { - touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer); - } - if (i.settings.useKeyboard) { - keyboardHandler(element); - } - updateGeometry(element); }; },{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){ 'use strict'; -var cls = require('../lib/class') - , d = require('../lib/dom') - , defaultSettings = require('./default-setting') - , EventManager = require('../lib/event-manager') - , guid = require('../lib/guid') - , h = require('../lib/helper'); +var _ = require('../lib/helper'); +var cls = require('../lib/class'); +var defaultSettings = require('./default-setting'); +var dom = require('../lib/dom'); +var EventManager = require('../lib/event-manager'); +var guid = require('../lib/guid'); var instances = {}; function Instance(element) { var i = this; - i.settings = h.clone(defaultSettings); + i.settings = _.clone(defaultSettings); i.containerWidth = null; i.containerHeight = null; i.contentWidth = null; i.contentHeight = null; - i.isRtl = d.css(element, 'direction') === "rtl"; + i.isRtl = dom.css(element, 'direction') === "rtl"; i.isNegativeScroll = (function () { var originalScrollLeft = element.scrollLeft; var result = null; @@ -1227,67 +1243,55 @@ function Instance(element) { cls.remove(element, 'ps-focus'); } - i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element); - i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail); + i.scrollbarXRail = dom.appendTo(dom.e('div', 'ps-scrollbar-x-rail'), element); + i.scrollbarX = dom.appendTo(dom.e('div', 'ps-scrollbar-x'), i.scrollbarXRail); i.scrollbarX.setAttribute('tabindex', 0); i.event.bind(i.scrollbarX, 'focus', focus); i.event.bind(i.scrollbarX, 'blur', blur); i.scrollbarXActive = null; i.scrollbarXWidth = null; i.scrollbarXLeft = null; - i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom')); + i.scrollbarXBottom = _.toInt(dom.css(i.scrollbarXRail, 'bottom')); i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN - i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top')); - i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth')); + i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : _.toInt(dom.css(i.scrollbarXRail, 'top')); + i.railBorderXWidth = _.toInt(dom.css(i.scrollbarXRail, 'borderLeftWidth')) + _.toInt(dom.css(i.scrollbarXRail, 'borderRightWidth')); // Set rail to display:block to calculate margins - d.css(i.scrollbarXRail, 'display', 'block'); - i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); - d.css(i.scrollbarXRail, 'display', ''); + dom.css(i.scrollbarXRail, 'display', 'block'); + i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight')); + dom.css(i.scrollbarXRail, 'display', ''); i.railXWidth = null; i.railXRatio = null; - i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element); - i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail); + i.scrollbarYRail = dom.appendTo(dom.e('div', 'ps-scrollbar-y-rail'), element); + i.scrollbarY = dom.appendTo(dom.e('div', 'ps-scrollbar-y'), i.scrollbarYRail); i.scrollbarY.setAttribute('tabindex', 0); i.event.bind(i.scrollbarY, 'focus', focus); i.event.bind(i.scrollbarY, 'blur', blur); i.scrollbarYActive = null; i.scrollbarYHeight = null; i.scrollbarYTop = null; - i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right')); + i.scrollbarYRight = _.toInt(dom.css(i.scrollbarYRail, 'right')); i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN - i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left')); - i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null; - i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth')); - d.css(i.scrollbarYRail, 'display', 'block'); - i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); - d.css(i.scrollbarYRail, 'display', ''); + i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : _.toInt(dom.css(i.scrollbarYRail, 'left')); + i.scrollbarYOuterWidth = i.isRtl ? _.outerWidth(i.scrollbarY) : null; + i.railBorderYWidth = _.toInt(dom.css(i.scrollbarYRail, 'borderTopWidth')) + _.toInt(dom.css(i.scrollbarYRail, 'borderBottomWidth')); + dom.css(i.scrollbarYRail, 'display', 'block'); + i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom')); + dom.css(i.scrollbarYRail, 'display', ''); i.railYHeight = null; i.railYRatio = null; } function getId(element) { - if (typeof element.dataset === 'undefined') { - return element.getAttribute('data-ps-id'); - } else { - return element.dataset.psId; - } + return element.getAttribute('data-ps-id'); } function setId(element, id) { - if (typeof element.dataset === 'undefined') { - element.setAttribute('data-ps-id', id); - } else { - element.dataset.psId = id; - } + element.setAttribute('data-ps-id', id); } function removeId(element) { - if (typeof element.dataset === 'undefined') { - element.removeAttribute('data-ps-id'); - } else { - delete element.dataset.psId; - } + element.removeAttribute('data-ps-id'); } exports.add = function (element) { @@ -1309,11 +1313,11 @@ exports.get = function (element) { },{"../lib/class":2,"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){ 'use strict'; -var cls = require('../lib/class') - , d = require('../lib/dom') - , h = require('../lib/helper') - , instances = require('./instances') - , updateScroll = require('./update-scroll'); +var _ = require('../lib/helper'); +var cls = require('../lib/class'); +var dom = require('../lib/dom'); +var instances = require('./instances'); +var updateScroll = require('./update-scroll'); function getThumbSize(i, thumbSize) { if (i.settings.minScrollbarLength) { @@ -1337,7 +1341,7 @@ function updateCss(element, i) { } else { xRailOffset.top = i.scrollbarXTop + element.scrollTop; } - d.css(i.scrollbarXRail, xRailOffset); + dom.css(i.scrollbarXRail, xRailOffset); var yRailOffset = {top: element.scrollTop, height: i.railYHeight}; if (i.isScrollbarYUsingRight) { @@ -1353,10 +1357,10 @@ function updateCss(element, i) { yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; } } - d.css(i.scrollbarYRail, yRailOffset); + dom.css(i.scrollbarYRail, yRailOffset); - d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth}); - d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth}); + dom.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth}); + dom.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth}); } module.exports = function (element) { @@ -1369,30 +1373,30 @@ module.exports = function (element) { var existingRails; if (!element.contains(i.scrollbarXRail)) { - existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail'); + existingRails = dom.queryChildren(element, '.ps-scrollbar-x-rail'); if (existingRails.length > 0) { existingRails.forEach(function (rail) { - d.remove(rail); + dom.remove(rail); }); } - d.appendTo(i.scrollbarXRail, element); + dom.appendTo(i.scrollbarXRail, element); } if (!element.contains(i.scrollbarYRail)) { - existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail'); + existingRails = dom.queryChildren(element, '.ps-scrollbar-y-rail'); if (existingRails.length > 0) { existingRails.forEach(function (rail) { - d.remove(rail); + dom.remove(rail); }); } - d.appendTo(i.scrollbarYRail, element); + dom.appendTo(i.scrollbarYRail, element); } if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) { i.scrollbarXActive = true; i.railXWidth = i.containerWidth - i.railXMarginWidth; i.railXRatio = i.containerWidth / i.railXWidth; - i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth)); - i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth)); + i.scrollbarXWidth = getThumbSize(i, _.toInt(i.railXWidth * i.containerWidth / i.contentWidth)); + i.scrollbarXLeft = _.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth)); } else { i.scrollbarXActive = false; } @@ -1401,8 +1405,8 @@ module.exports = function (element) { i.scrollbarYActive = true; i.railYHeight = i.containerHeight - i.railYMarginHeight; i.railYRatio = i.containerHeight / i.railYHeight; - i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight)); - i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight)); + i.scrollbarYHeight = getThumbSize(i, _.toInt(i.railYHeight * i.containerHeight / i.contentHeight)); + i.scrollbarYTop = _.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight)); } else { i.scrollbarYActive = false; } @@ -1439,29 +1443,14 @@ module.exports = function (element) { var instances = require('./instances'); -var upEvent = document.createEvent('Event') - , downEvent = document.createEvent('Event') - , leftEvent = document.createEvent('Event') - , rightEvent = document.createEvent('Event') - , yEvent = document.createEvent('Event') - , xEvent = document.createEvent('Event') - , xStartEvent = document.createEvent('Event') - , xEndEvent = document.createEvent('Event') - , yStartEvent = document.createEvent('Event') - , yEndEvent = document.createEvent('Event') - , lastTop - , lastLeft; +var lastTop; +var lastLeft; -upEvent.initEvent('ps-scroll-up', true, true); -downEvent.initEvent('ps-scroll-down', true, true); -leftEvent.initEvent('ps-scroll-left', true, true); -rightEvent.initEvent('ps-scroll-right', true, true); -yEvent.initEvent('ps-scroll-y', true, true); -xEvent.initEvent('ps-scroll-x', true, true); -xStartEvent.initEvent('ps-x-reach-start', true, true); -xEndEvent.initEvent('ps-x-reach-end', true, true); -yStartEvent.initEvent('ps-y-reach-start', true, true); -yEndEvent.initEvent('ps-y-reach-end', true, true); +var createDOMEvent = function (name) { + var event = document.createEvent("Event"); + event.initEvent(name, true, true); + return event; +}; module.exports = function (element, axis, value) { if (typeof element === 'undefined') { @@ -1478,24 +1467,38 @@ module.exports = function (element, axis, value) { if (axis === 'top' && value <= 0) { element.scrollTop = value = 0; // don't allow negative scroll - element.dispatchEvent(yStartEvent); + element.dispatchEvent(createDOMEvent('ps-y-reach-start')); } if (axis === 'left' && value <= 0) { element.scrollLeft = value = 0; // don't allow negative scroll - element.dispatchEvent(xStartEvent); + element.dispatchEvent(createDOMEvent('ps-x-reach-start')); } var i = instances.get(element); if (axis === 'top' && value >= i.contentHeight - i.containerHeight) { - element.scrollTop = value = i.contentHeight - i.containerHeight; // don't allow scroll past container - element.dispatchEvent(yEndEvent); + // don't allow scroll past container + value = i.contentHeight - i.containerHeight; + if (value - element.scrollTop <= 1) { + // mitigates rounding errors on non-subpixel scroll values + value = element.scrollTop; + } else { + element.scrollTop = value; + } + element.dispatchEvent(createDOMEvent('ps-y-reach-end')); } if (axis === 'left' && value >= i.contentWidth - i.containerWidth) { - element.scrollLeft = value = i.contentWidth - i.containerWidth; // don't allow scroll past container - element.dispatchEvent(xEndEvent); + // don't allow scroll past container + value = i.contentWidth - i.containerWidth; + if (value - element.scrollLeft <= 1) { + // mitigates rounding errors on non-subpixel scroll values + value = element.scrollLeft; + } else { + element.scrollLeft = value; + } + element.dispatchEvent(createDOMEvent('ps-x-reach-end')); } if (!lastTop) { @@ -1507,29 +1510,29 @@ module.exports = function (element, axis, value) { } if (axis === 'top' && value < lastTop) { - element.dispatchEvent(upEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-up')); } if (axis === 'top' && value > lastTop) { - element.dispatchEvent(downEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-down')); } if (axis === 'left' && value < lastLeft) { - element.dispatchEvent(leftEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-left')); } if (axis === 'left' && value > lastLeft) { - element.dispatchEvent(rightEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-right')); } if (axis === 'top') { element.scrollTop = lastTop = value; - element.dispatchEvent(yEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-y')); } if (axis === 'left') { element.scrollLeft = lastLeft = value; - element.dispatchEvent(xEvent); + element.dispatchEvent(createDOMEvent('ps-scroll-x')); } }; @@ -1537,11 +1540,11 @@ module.exports = function (element, axis, value) { },{"./instances":18}],21:[function(require,module,exports){ 'use strict'; -var d = require('../lib/dom') - , h = require('../lib/helper') - , instances = require('./instances') - , updateGeometry = require('./update-geometry') - , updateScroll = require('./update-scroll'); +var _ = require('../lib/helper'); +var dom = require('../lib/dom'); +var instances = require('./instances'); +var updateGeometry = require('./update-geometry'); +var updateScroll = require('./update-scroll'); module.exports = function (element) { var i = instances.get(element); @@ -1554,14 +1557,14 @@ module.exports = function (element) { i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0; // Recalculate rail margins - d.css(i.scrollbarXRail, 'display', 'block'); - d.css(i.scrollbarYRail, 'display', 'block'); - i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight')); - i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom')); + dom.css(i.scrollbarXRail, 'display', 'block'); + dom.css(i.scrollbarYRail, 'display', 'block'); + i.railXMarginWidth = _.toInt(dom.css(i.scrollbarXRail, 'marginLeft')) + _.toInt(dom.css(i.scrollbarXRail, 'marginRight')); + i.railYMarginHeight = _.toInt(dom.css(i.scrollbarYRail, 'marginTop')) + _.toInt(dom.css(i.scrollbarYRail, 'marginBottom')); // Hide scrollbars not to affect scrollWidth and scrollHeight - d.css(i.scrollbarXRail, 'display', 'none'); - d.css(i.scrollbarYRail, 'display', 'none'); + dom.css(i.scrollbarXRail, 'display', 'none'); + dom.css(i.scrollbarYRail, 'display', 'none'); updateGeometry(element); @@ -1569,8 +1572,8 @@ module.exports = function (element) { updateScroll(element, 'top', element.scrollTop); updateScroll(element, 'left', element.scrollLeft); - d.css(i.scrollbarXRail, 'display', ''); - d.css(i.scrollbarYRail, 'display', ''); + dom.css(i.scrollbarXRail, 'display', ''); + dom.css(i.scrollbarYRail, 'display', ''); }; },{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]); diff --git a/library/perfect-scrollbar/perfect-scrollbar.jquery.min.js b/library/perfect-scrollbar/perfect-scrollbar.jquery.min.js new file mode 100644 index 0000000000..acb198df5a --- /dev/null +++ b/library/perfect-scrollbar/perfect-scrollbar.jquery.min.js @@ -0,0 +1,2 @@ +/* perfect-scrollbar v0.6.15 */ +!function t(e,n,r){function o(i,s){if(!n[i]){if(!e[i]){var a="function"==typeof require&&require;if(!s&&a)return a(i,!0);if(l)return l(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};e[i][0].call(u.exports,function(t){var n=e[i][1][t];return o(n?n:t)},u,u.exports,t,e,n,r)}return n[i].exports}for(var l="function"==typeof require&&require,i=0;i=0&&n.splice(r,1),t.className=n.join(" ")}n.add=function(t,e){t.classList?t.classList.add(e):r(t,e)},n.remove=function(t,e){t.classList?t.classList.remove(e):o(t,e)},n.list=function(t){return t.classList?Array.prototype.slice.apply(t.classList):t.className.split(" ")}},{}],3:[function(t,e,n){"use strict";function r(t,e){return window.getComputedStyle(t)[e]}function o(t,e,n){return"number"==typeof n&&(n=n.toString()+"px"),t.style[e]=n,t}function l(t,e){for(var n in e){var r=e[n];"number"==typeof r&&(r=r.toString()+"px"),t.style[n]=r}return t}var i={};i.e=function(t,e){var n=document.createElement(t);return n.className=e,n},i.appendTo=function(t,e){return e.appendChild(t),t},i.css=function(t,e,n){return"object"==typeof e?l(t,e):"undefined"==typeof n?r(t,e):o(t,e,n)},i.matches=function(t,e){return"undefined"!=typeof t.matches?t.matches(e):"undefined"!=typeof t.matchesSelector?t.matchesSelector(e):"undefined"!=typeof t.webkitMatchesSelector?t.webkitMatchesSelector(e):"undefined"!=typeof t.mozMatchesSelector?t.mozMatchesSelector(e):"undefined"!=typeof t.msMatchesSelector?t.msMatchesSelector(e):void 0},i.remove=function(t){"undefined"!=typeof t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)},i.queryChildren=function(t,e){return Array.prototype.filter.call(t.childNodes,function(t){return i.matches(t,e)})},e.exports=i},{}],4:[function(t,e,n){"use strict";var r=function(t){this.element=t,this.events={}};r.prototype.bind=function(t,e){"undefined"==typeof this.events[t]&&(this.events[t]=[]),this.events[t].push(e),this.element.addEventListener(t,e,!1)},r.prototype.unbind=function(t,e){var n="undefined"!=typeof e;this.events[t]=this.events[t].filter(function(r){return!(!n||r===e)||(this.element.removeEventListener(t,r,!1),!1)},this)},r.prototype.unbindAll=function(){for(var t in this.events)this.unbind(t)};var o=function(){this.eventElements=[]};o.prototype.eventElement=function(t){var e=this.eventElements.filter(function(e){return e.element===t})[0];return"undefined"==typeof e&&(e=new r(t),this.eventElements.push(e)),e},o.prototype.bind=function(t,e,n){this.eventElement(t).bind(e,n)},o.prototype.unbind=function(t,e,n){this.eventElement(t).unbind(e,n)},o.prototype.unbindAll=function(){for(var t=0;te.scrollbarYTop?1:-1;i(t,"top",t.scrollTop+s*e.containerHeight),l(t),r.stopPropagation()}),e.event.bind(e.scrollbarX,"click",r),e.event.bind(e.scrollbarXRail,"click",function(r){var o=r.pageX-window.pageXOffset-n(e.scrollbarXRail).left,s=o>e.scrollbarXLeft?1:-1;i(t,"left",t.scrollLeft+s*e.containerWidth),l(t),r.stopPropagation()})}var o=t("../instances"),l=t("../update-geometry"),i=t("../update-scroll");e.exports=function(t){var e=o.get(t);r(t,e)}},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(t,e,n){"use strict";function r(t,e){function n(n){var o=r+n*e.railXRatio,i=Math.max(0,e.scrollbarXRail.getBoundingClientRect().left)+e.railXRatio*(e.railXWidth-e.scrollbarXWidth);o<0?e.scrollbarXLeft=0:o>i?e.scrollbarXLeft=i:e.scrollbarXLeft=o;var s=l.toInt(e.scrollbarXLeft*(e.contentWidth-e.containerWidth)/(e.containerWidth-e.railXRatio*e.scrollbarXWidth))-e.negativeScrollAdjustment;c(t,"left",s)}var r=null,o=null,s=function(e){n(e.pageX-o),a(t),e.stopPropagation(),e.preventDefault()},u=function(){l.stopScrolling(t,"x"),e.event.unbind(e.ownerDocument,"mousemove",s)};e.event.bind(e.scrollbarX,"mousedown",function(n){o=n.pageX,r=l.toInt(i.css(e.scrollbarX,"left"))*e.railXRatio,l.startScrolling(t,"x"),e.event.bind(e.ownerDocument,"mousemove",s),e.event.once(e.ownerDocument,"mouseup",u),n.stopPropagation(),n.preventDefault()})}function o(t,e){function n(n){var o=r+n*e.railYRatio,i=Math.max(0,e.scrollbarYRail.getBoundingClientRect().top)+e.railYRatio*(e.railYHeight-e.scrollbarYHeight);o<0?e.scrollbarYTop=0:o>i?e.scrollbarYTop=i:e.scrollbarYTop=o;var s=l.toInt(e.scrollbarYTop*(e.contentHeight-e.containerHeight)/(e.containerHeight-e.railYRatio*e.scrollbarYHeight));c(t,"top",s)}var r=null,o=null,s=function(e){n(e.pageY-o),a(t),e.stopPropagation(),e.preventDefault()},u=function(){l.stopScrolling(t,"y"),e.event.unbind(e.ownerDocument,"mousemove",s)};e.event.bind(e.scrollbarY,"mousedown",function(n){o=n.pageY,r=l.toInt(i.css(e.scrollbarY,"top"))*e.railYRatio,l.startScrolling(t,"y"),e.event.bind(e.ownerDocument,"mousemove",s),e.event.once(e.ownerDocument,"mouseup",u),n.stopPropagation(),n.preventDefault()})}var l=t("../../lib/helper"),i=t("../../lib/dom"),s=t("../instances"),a=t("../update-geometry"),c=t("../update-scroll");e.exports=function(t){var e=s.get(t);r(t,e),o(t,e)}},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(t,e,n){"use strict";function r(t,e){function n(n,r){var o=t.scrollTop;if(0===n){if(!e.scrollbarYActive)return!1;if(0===o&&r>0||o>=e.contentHeight-e.containerHeight&&r<0)return!e.settings.wheelPropagation}var l=t.scrollLeft;if(0===r){if(!e.scrollbarXActive)return!1;if(0===l&&n<0||l>=e.contentWidth-e.containerWidth&&n>0)return!e.settings.wheelPropagation}return!0}var r=!1;e.event.bind(t,"mouseenter",function(){r=!0}),e.event.bind(t,"mouseleave",function(){r=!1});var i=!1;e.event.bind(e.ownerDocument,"keydown",function(c){if(!(c.isDefaultPrevented&&c.isDefaultPrevented()||c.defaultPrevented)){var u=l.matches(e.scrollbarX,":focus")||l.matches(e.scrollbarY,":focus");if(r||u){var d=document.activeElement?document.activeElement:e.ownerDocument.activeElement;if(d){if("IFRAME"===d.tagName)d=d.contentDocument.activeElement;else for(;d.shadowRoot;)d=d.shadowRoot.activeElement;if(o.isEditable(d))return}var p=0,f=0;switch(c.which){case 37:p=c.metaKey?-e.contentWidth:c.altKey?-e.containerWidth:-30;break;case 38:f=c.metaKey?e.contentHeight:c.altKey?e.containerHeight:30;break;case 39:p=c.metaKey?e.contentWidth:c.altKey?e.containerWidth:30;break;case 40:f=c.metaKey?-e.contentHeight:c.altKey?-e.containerHeight:-30;break;case 33:f=90;break;case 32:f=c.shiftKey?90:-90;break;case 34:f=-90;break;case 35:f=c.ctrlKey?-e.contentHeight:-e.containerHeight;break;case 36:f=c.ctrlKey?t.scrollTop:e.containerHeight;break;default:return}a(t,"top",t.scrollTop-f),a(t,"left",t.scrollLeft+p),s(t),i=n(p,f),i&&c.preventDefault()}}})}var o=t("../../lib/helper"),l=t("../../lib/dom"),i=t("../instances"),s=t("../update-geometry"),a=t("../update-scroll");e.exports=function(t){var e=i.get(t);r(t,e)}},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(t,e,n){"use strict";function r(t,e){function n(n,r){var o=t.scrollTop;if(0===n){if(!e.scrollbarYActive)return!1;if(0===o&&r>0||o>=e.contentHeight-e.containerHeight&&r<0)return!e.settings.wheelPropagation}var l=t.scrollLeft;if(0===r){if(!e.scrollbarXActive)return!1;if(0===l&&n<0||l>=e.contentWidth-e.containerWidth&&n>0)return!e.settings.wheelPropagation}return!0}function r(t){var e=t.deltaX,n=-1*t.deltaY;return"undefined"!=typeof e&&"undefined"!=typeof n||(e=-1*t.wheelDeltaX/6,n=t.wheelDeltaY/6),t.deltaMode&&1===t.deltaMode&&(e*=10,n*=10),e!==e&&n!==n&&(e=0,n=t.wheelDelta),t.shiftKey?[-n,-e]:[e,n]}function o(e,n){var r=t.querySelector("textarea:hover, select[multiple]:hover, .ps-child:hover");if(r){if(!window.getComputedStyle(r).overflow.match(/(scroll|auto)/))return!1;var o=r.scrollHeight-r.clientHeight;if(o>0&&!(0===r.scrollTop&&n>0||r.scrollTop===o&&n<0))return!0;var l=r.scrollLeft-r.clientWidth;if(l>0&&!(0===r.scrollLeft&&e<0||r.scrollLeft===l&&e>0))return!0}return!1}function s(s){var c=r(s),u=c[0],d=c[1];o(u,d)||(a=!1,e.settings.useBothWheelAxes?e.scrollbarYActive&&!e.scrollbarXActive?(d?i(t,"top",t.scrollTop-d*e.settings.wheelSpeed):i(t,"top",t.scrollTop+u*e.settings.wheelSpeed),a=!0):e.scrollbarXActive&&!e.scrollbarYActive&&(u?i(t,"left",t.scrollLeft+u*e.settings.wheelSpeed):i(t,"left",t.scrollLeft-d*e.settings.wheelSpeed),a=!0):(i(t,"top",t.scrollTop-d*e.settings.wheelSpeed),i(t,"left",t.scrollLeft+u*e.settings.wheelSpeed)),l(t),a=a||n(u,d),a&&(s.stopPropagation(),s.preventDefault()))}var a=!1;"undefined"!=typeof window.onwheel?e.event.bind(t,"wheel",s):"undefined"!=typeof window.onmousewheel&&e.event.bind(t,"mousewheel",s)}var o=t("../instances"),l=t("../update-geometry"),i=t("../update-scroll");e.exports=function(t){var e=o.get(t);r(t,e)}},{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(t,e,n){"use strict";function r(t,e){e.event.bind(t,"scroll",function(){l(t)})}var o=t("../instances"),l=t("../update-geometry");e.exports=function(t){var e=o.get(t);r(t,e)}},{"../instances":18,"../update-geometry":19}],15:[function(t,e,n){"use strict";function r(t,e){function n(){var t=window.getSelection?window.getSelection():document.getSelection?document.getSelection():"";return 0===t.toString().length?null:t.getRangeAt(0).commonAncestorContainer}function r(){c||(c=setInterval(function(){return l.get(t)?(s(t,"top",t.scrollTop+u.top),s(t,"left",t.scrollLeft+u.left),void i(t)):void clearInterval(c)},50))}function a(){c&&(clearInterval(c),c=null),o.stopScrolling(t)}var c=null,u={top:0,left:0},d=!1;e.event.bind(e.ownerDocument,"selectionchange",function(){t.contains(n())?d=!0:(d=!1,a())}),e.event.bind(window,"mouseup",function(){d&&(d=!1,a())}),e.event.bind(window,"keyup",function(){d&&(d=!1,a())}),e.event.bind(window,"mousemove",function(e){if(d){var n={x:e.pageX,y:e.pageY},l={left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,bottom:t.offsetTop+t.offsetHeight};n.xl.right-3?(u.left=5,o.startScrolling(t,"x")):u.left=0,n.yl.bottom-3?(n.y-l.bottom+3<5?u.top=5:u.top=20,o.startScrolling(t,"y")):u.top=0,0===u.top&&0===u.left?a():r()}})}var o=t("../../lib/helper"),l=t("../instances"),i=t("../update-geometry"),s=t("../update-scroll");e.exports=function(t){var e=l.get(t);r(t,e)}},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(t,e,n){"use strict";function r(t,e,n,r){function o(n,r){var o=t.scrollTop,l=t.scrollLeft,i=Math.abs(n),s=Math.abs(r);if(s>i){if(r<0&&o===e.contentHeight-e.containerHeight||r>0&&0===o)return!e.settings.swipePropagation}else if(i>s&&(n<0&&l===e.contentWidth-e.containerWidth||n>0&&0===l))return!e.settings.swipePropagation;return!0}function a(e,n){s(t,"top",t.scrollTop-n),s(t,"left",t.scrollLeft-e),i(t)}function c(){w=!0}function u(){w=!1}function d(t){return t.targetTouches?t.targetTouches[0]:t}function p(t){return!(!t.targetTouches||1!==t.targetTouches.length)||!(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE)}function f(t){if(p(t)){Y=!0;var e=d(t);g.pageX=e.pageX,g.pageY=e.pageY,v=(new Date).getTime(),null!==y&&clearInterval(y),t.stopPropagation()}}function h(t){if(!Y&&e.settings.swipePropagation&&f(t),!w&&Y&&p(t)){var n=d(t),r={pageX:n.pageX,pageY:n.pageY},l=r.pageX-g.pageX,i=r.pageY-g.pageY;a(l,i),g=r;var s=(new Date).getTime(),c=s-v;c>0&&(m.x=l/c,m.y=i/c,v=s),o(l,i)&&(t.stopPropagation(),t.preventDefault())}}function b(){!w&&Y&&(Y=!1,clearInterval(y),y=setInterval(function(){return l.get(t)&&(m.x||m.y)?Math.abs(m.x)<.01&&Math.abs(m.y)<.01?void clearInterval(y):(a(30*m.x,30*m.y),m.x*=.8,void(m.y*=.8)):void clearInterval(y)},10))}var g={},v=0,m={},y=null,w=!1,Y=!1;n&&(e.event.bind(window,"touchstart",c),e.event.bind(window,"touchend",u),e.event.bind(t,"touchstart",f),e.event.bind(t,"touchmove",h),e.event.bind(t,"touchend",b)),r&&(window.PointerEvent?(e.event.bind(window,"pointerdown",c),e.event.bind(window,"pointerup",u),e.event.bind(t,"pointerdown",f),e.event.bind(t,"pointermove",h),e.event.bind(t,"pointerup",b)):window.MSPointerEvent&&(e.event.bind(window,"MSPointerDown",c),e.event.bind(window,"MSPointerUp",u),e.event.bind(t,"MSPointerDown",f),e.event.bind(t,"MSPointerMove",h),e.event.bind(t,"MSPointerUp",b)))}var o=t("../../lib/helper"),l=t("../instances"),i=t("../update-geometry"),s=t("../update-scroll");e.exports=function(t){if(o.env.supportsTouch||o.env.supportsIePointer){var e=l.get(t);r(t,e,o.env.supportsTouch,o.env.supportsIePointer)}}},{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(t,e,n){"use strict";var r=t("../lib/helper"),o=t("../lib/class"),l=t("./instances"),i=t("./update-geometry"),s={"click-rail":t("./handler/click-rail"),"drag-scrollbar":t("./handler/drag-scrollbar"),keyboard:t("./handler/keyboard"),wheel:t("./handler/mouse-wheel"),touch:t("./handler/touch"),selection:t("./handler/selection")},a=t("./handler/native-scroll");e.exports=function(t,e){e="object"==typeof e?e:{},o.add(t,"ps-container");var n=l.add(t);n.settings=r.extend(n.settings,e),o.add(t,"ps-theme-"+n.settings.theme),n.settings.handlers.forEach(function(e){s[e](t)}),a(t),i(t)}},{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(t,e,n){"use strict";function r(t){function e(){a.add(t,"ps-focus")}function n(){a.remove(t,"ps-focus")}var r=this;r.settings=s.clone(c),r.containerWidth=null,r.containerHeight=null,r.contentWidth=null,r.contentHeight=null,r.isRtl="rtl"===u.css(t,"direction"),r.isNegativeScroll=function(){var e=t.scrollLeft,n=null;return t.scrollLeft=-1,n=t.scrollLeft<0,t.scrollLeft=e,n}(),r.negativeScrollAdjustment=r.isNegativeScroll?t.scrollWidth-t.clientWidth:0,r.event=new d,r.ownerDocument=t.ownerDocument||document,r.scrollbarXRail=u.appendTo(u.e("div","ps-scrollbar-x-rail"),t),r.scrollbarX=u.appendTo(u.e("div","ps-scrollbar-x"),r.scrollbarXRail),r.scrollbarX.setAttribute("tabindex",0),r.event.bind(r.scrollbarX,"focus",e),r.event.bind(r.scrollbarX,"blur",n),r.scrollbarXActive=null,r.scrollbarXWidth=null,r.scrollbarXLeft=null,r.scrollbarXBottom=s.toInt(u.css(r.scrollbarXRail,"bottom")),r.isScrollbarXUsingBottom=r.scrollbarXBottom===r.scrollbarXBottom,r.scrollbarXTop=r.isScrollbarXUsingBottom?null:s.toInt(u.css(r.scrollbarXRail,"top")),r.railBorderXWidth=s.toInt(u.css(r.scrollbarXRail,"borderLeftWidth"))+s.toInt(u.css(r.scrollbarXRail,"borderRightWidth")),u.css(r.scrollbarXRail,"display","block"),r.railXMarginWidth=s.toInt(u.css(r.scrollbarXRail,"marginLeft"))+s.toInt(u.css(r.scrollbarXRail,"marginRight")),u.css(r.scrollbarXRail,"display",""),r.railXWidth=null,r.railXRatio=null,r.scrollbarYRail=u.appendTo(u.e("div","ps-scrollbar-y-rail"),t),r.scrollbarY=u.appendTo(u.e("div","ps-scrollbar-y"),r.scrollbarYRail),r.scrollbarY.setAttribute("tabindex",0),r.event.bind(r.scrollbarY,"focus",e),r.event.bind(r.scrollbarY,"blur",n),r.scrollbarYActive=null,r.scrollbarYHeight=null,r.scrollbarYTop=null,r.scrollbarYRight=s.toInt(u.css(r.scrollbarYRail,"right")),r.isScrollbarYUsingRight=r.scrollbarYRight===r.scrollbarYRight,r.scrollbarYLeft=r.isScrollbarYUsingRight?null:s.toInt(u.css(r.scrollbarYRail,"left")),r.scrollbarYOuterWidth=r.isRtl?s.outerWidth(r.scrollbarY):null,r.railBorderYWidth=s.toInt(u.css(r.scrollbarYRail,"borderTopWidth"))+s.toInt(u.css(r.scrollbarYRail,"borderBottomWidth")),u.css(r.scrollbarYRail,"display","block"),r.railYMarginHeight=s.toInt(u.css(r.scrollbarYRail,"marginTop"))+s.toInt(u.css(r.scrollbarYRail,"marginBottom")),u.css(r.scrollbarYRail,"display",""),r.railYHeight=null,r.railYRatio=null}function o(t){return t.getAttribute("data-ps-id")}function l(t,e){t.setAttribute("data-ps-id",e)}function i(t){t.removeAttribute("data-ps-id")}var s=t("../lib/helper"),a=t("../lib/class"),c=t("./default-setting"),u=t("../lib/dom"),d=t("../lib/event-manager"),p=t("../lib/guid"),f={};n.add=function(t){var e=p();return l(t,e),f[e]=new r(t),f[e]},n.remove=function(t){delete f[o(t)],i(t)},n.get=function(t){return f[o(t)]}},{"../lib/class":2,"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(t,e,n){"use strict";function r(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function o(t,e){var n={width:e.railXWidth};e.isRtl?n.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:n.left=t.scrollLeft,e.isScrollbarXUsingBottom?n.bottom=e.scrollbarXBottom-t.scrollTop:n.top=e.scrollbarXTop+t.scrollTop,s.css(e.scrollbarXRail,n);var r={top:t.scrollTop,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?r.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth:r.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?r.left=e.negativeScrollAdjustment+t.scrollLeft+2*e.containerWidth-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:r.left=e.scrollbarYLeft+t.scrollLeft,s.css(e.scrollbarYRail,r),s.css(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),s.css(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}var l=t("../lib/helper"),i=t("../lib/class"),s=t("../lib/dom"),a=t("./instances"),c=t("./update-scroll");e.exports=function(t){var e=a.get(t);e.containerWidth=t.clientWidth,e.containerHeight=t.clientHeight,e.contentWidth=t.scrollWidth,e.contentHeight=t.scrollHeight;var n;t.contains(e.scrollbarXRail)||(n=s.queryChildren(t,".ps-scrollbar-x-rail"),n.length>0&&n.forEach(function(t){s.remove(t)}),s.appendTo(e.scrollbarXRail,t)),t.contains(e.scrollbarYRail)||(n=s.queryChildren(t,".ps-scrollbar-y-rail"),n.length>0&&n.forEach(function(t){s.remove(t)}),s.appendTo(e.scrollbarYRail,t)),!e.settings.suppressScrollX&&e.containerWidth+e.settings.scrollXMarginOffset=e.railXWidth-e.scrollbarXWidth&&(e.scrollbarXLeft=e.railXWidth-e.scrollbarXWidth),e.scrollbarYTop>=e.railYHeight-e.scrollbarYHeight&&(e.scrollbarYTop=e.railYHeight-e.scrollbarYHeight),o(t,e),e.scrollbarXActive?i.add(t,"ps-active-x"):(i.remove(t,"ps-active-x"),e.scrollbarXWidth=0,e.scrollbarXLeft=0,c(t,"left",0)),e.scrollbarYActive?i.add(t,"ps-active-y"):(i.remove(t,"ps-active-y"),e.scrollbarYHeight=0,e.scrollbarYTop=0,c(t,"top",0))}},{"../lib/class":2,"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-scroll":20}],20:[function(t,e,n){"use strict";var r,o,l=t("./instances"),i=function(t){var e=document.createEvent("Event");return e.initEvent(t,!0,!0),e};e.exports=function(t,e,n){if("undefined"==typeof t)throw"You must provide an element to the update-scroll function";if("undefined"==typeof e)throw"You must provide an axis to the update-scroll function";if("undefined"==typeof n)throw"You must provide a value to the update-scroll function";"top"===e&&n<=0&&(t.scrollTop=n=0,t.dispatchEvent(i("ps-y-reach-start"))),"left"===e&&n<=0&&(t.scrollLeft=n=0,t.dispatchEvent(i("ps-x-reach-start")));var s=l.get(t);"top"===e&&n>=s.contentHeight-s.containerHeight&&(n=s.contentHeight-s.containerHeight,n-t.scrollTop<=1?n=t.scrollTop:t.scrollTop=n,t.dispatchEvent(i("ps-y-reach-end"))),"left"===e&&n>=s.contentWidth-s.containerWidth&&(n=s.contentWidth-s.containerWidth,n-t.scrollLeft<=1?n=t.scrollLeft:t.scrollLeft=n,t.dispatchEvent(i("ps-x-reach-end"))),r||(r=t.scrollTop),o||(o=t.scrollLeft),"top"===e&&nr&&t.dispatchEvent(i("ps-scroll-down")),"left"===e&&no&&t.dispatchEvent(i("ps-scroll-right")),"top"===e&&(t.scrollTop=r=n,t.dispatchEvent(i("ps-scroll-y"))),"left"===e&&(t.scrollLeft=o=n,t.dispatchEvent(i("ps-scroll-x")))}},{"./instances":18}],21:[function(t,e,n){"use strict";var r=t("../lib/helper"),o=t("../lib/dom"),l=t("./instances"),i=t("./update-geometry"),s=t("./update-scroll");e.exports=function(t){var e=l.get(t);e&&(e.negativeScrollAdjustment=e.isNegativeScroll?t.scrollWidth-t.clientWidth:0,o.css(e.scrollbarXRail,"display","block"),o.css(e.scrollbarYRail,"display","block"),e.railXMarginWidth=r.toInt(o.css(e.scrollbarXRail,"marginLeft"))+r.toInt(o.css(e.scrollbarXRail,"marginRight")),e.railYMarginHeight=r.toInt(o.css(e.scrollbarYRail,"marginTop"))+r.toInt(o.css(e.scrollbarYRail,"marginBottom")),o.css(e.scrollbarXRail,"display","none"),o.css(e.scrollbarYRail,"display","none"),i(t),s(t,"top",t.scrollTop),s(t,"left",t.scrollLeft),o.css(e.scrollbarXRail,"display",""),o.css(e.scrollbarYRail,"display",""))}},{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]); \ No newline at end of file diff --git a/library/perfect-scrollbar/perfect-scrollbar.min.css b/library/perfect-scrollbar/perfect-scrollbar.min.css index e8d2f37d9c..3eb93c4ba2 100644 --- a/library/perfect-scrollbar/perfect-scrollbar.min.css +++ b/library/perfect-scrollbar/perfect-scrollbar.min.css @@ -1,2 +1,2 @@ -/* perfect-scrollbar v0.6.10 */ -.ps-container{-ms-touch-action:none;touch-action:none;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps-container{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps-container{overflow:auto !important}}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block;background-color:transparent}.ps-container.ps-in-scrolling{pointer-events:none}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:3px;height:8px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;bottom:0;height:8px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:3px;width:8px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;right:0;width:8px}.ps-container:hover.ps-in-scrolling{pointer-events:none}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:0.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} +/* perfect-scrollbar v0.6.15 */ +.ps-container{-ms-touch-action:auto;touch-action:auto;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps-container{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps-container{overflow:auto !important}}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block;background-color:transparent}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999;height:11px}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999;width:11px}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:0px;height:15px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;bottom:2px;height:6px}.ps-container>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x,.ps-container>.ps-scrollbar-x-rail:active>.ps-scrollbar-x{height:11px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:0;width:15px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;right:2px;width:6px}.ps-container>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y,.ps-container>.ps-scrollbar-y-rail:active>.ps-scrollbar-y{width:11px}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999;height:11px}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999;width:11px}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} diff --git a/view/templates/head.tpl b/view/templates/head.tpl index cd6bc52a0f..0f1ec837f8 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -43,7 +43,7 @@ - + diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index f49b3045f4..6b21cb3db1 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -66,7 +66,7 @@ - + From 0d76796f30af76ca290dea5accc894a59b40d7b1 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 25 Dec 2016 01:47:18 +0100 Subject: [PATCH 07/15] Bugfix: fix handling with colorbox popups in frio --- js/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index b2a4dfe35c..1b7b304a24 100644 --- a/js/main.js +++ b/js/main.js @@ -161,10 +161,12 @@ // fancyboxes $("a.popupbox").colorbox({ 'inline' : true, - 'transition' : 'elastic' + 'transition' : 'elastic', + 'maxWidth' : '100%' }); $("a.ajax-popupbox").colorbox({ - 'transition' : 'elastic' + 'transition' : 'elastic', + 'maxWidth' : '100%' }); /* notifications template */ From 08fb35838c3a44aa65310a45fd6c42343fcd173a Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 25 Dec 2016 16:58:38 +0100 Subject: [PATCH 08/15] Update the photo albums cache on upload, album deletion or renaming --- mod/photos.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mod/photos.php b/mod/photos.php index a4bf19e940..24325f1cc5 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -208,6 +208,9 @@ function photos_post(&$a) { dbesc($album), intval($page_owner_uid) ); + // Update the photo albums cache + photo_albums($page_owner_uid, true); + $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']); goaway($newurl); return; // NOTREACHED @@ -294,7 +297,11 @@ function photos_post(&$a) { proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); } } + + // Update the photo albums cache + photo_albums($page_owner_uid, true); } + goaway('photos/' . $a->data['user']['nickname']); return; // NOTREACHED } @@ -359,6 +366,9 @@ function photos_post(&$a) { $url = App::get_baseurl(); $drop_id = intval($i[0]['id']); + // Update the photo albums cache + photo_albums($page_owner_uid, true); + if ($i[0]['visible']) proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); } @@ -457,6 +467,8 @@ function photos_post(&$a) { dbesc($resource_id), intval($page_owner_uid) ); + // Update the photo albums cache + photo_albums($page_owner_uid, true); } /* Don't make the item visible if the only change was the album name */ @@ -913,6 +925,8 @@ function photos_post(&$a) { . '[/url]'; $item_id = item_store($arr); + // Update the photo albums cache + photo_albums($page_owner_uid, true); if ($visible) proc_run(PRIORITY_HIGH, "include/notifier.php", 'wall-new', $item_id); From 3ba1ac595f0f1bed9acf110a7d20d7faae976450 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 25 Dec 2016 21:04:10 +0000 Subject: [PATCH 09/15] New binary data fields to avoid index length problems --- include/dbstructure.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index 50c2856ab6..3ff9efee79 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -464,13 +464,13 @@ function db_definition($charset) { ); $database["cache"] = array( "fields" => array( - "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), + "k" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), "v" => array("type" => "text"), "expire_mode" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("k".db_index_suffix($charset)), + "PRIMARY" => array("k"), "updated" => array("updated"), "expire_mode_updated" => array("expire_mode", "updated"), ) @@ -504,13 +504,13 @@ function db_definition($charset) { $database["config"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), "v" => array("type" => "text"), ), "indexes" => array( "PRIMARY" => array("id"), - "cat_k" => array("UNIQUE", "cat(30)","k(30)"), + "cat_k" => array("UNIQUE", "cat", "k"), ) ); $database["contact"] = array( @@ -610,7 +610,7 @@ function db_definition($charset) { $database["deliverq"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "cmd" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""), "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"), ), @@ -1092,25 +1092,25 @@ function db_definition($charset) { ); $database["oembed"] = array( "fields" => array( - "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), + "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), "content" => array("type" => "text"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("url".db_index_suffix($charset)), + "PRIMARY" => array("url"), "created" => array("created"), ) ); $database["parsed_url"] = array( "fields" => array( - "url" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"), + "url" => array("type" => "varbinary(255)", "not null" => "1", "primary" => "1"), "guessing" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), "oembed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0", "primary" => "1"), "content" => array("type" => "text"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( - "PRIMARY" => array("url".db_index_suffix($charset), "guessing", "oembed"), + "PRIMARY" => array("url", "guessing", "oembed"), "created" => array("created"), ) ); @@ -1118,13 +1118,13 @@ function db_definition($charset) { "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), - "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "cat" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), + "k" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), "v" => array("type" => "mediumtext"), ), "indexes" => array( "PRIMARY" => array("id"), - "uid_cat_k" => array("UNIQUE", "uid","cat(30)","k(30)"), + "uid_cat_k" => array("UNIQUE", "uid", "cat", "k"), ) ); $database["photo"] = array( @@ -1196,7 +1196,7 @@ function db_definition($charset) { $database["process"] = array( "fields" => array( "pid" => array("type" => "int(10) unsigned", "not null" => "1", "primary" => "1"), - "command" => array("type" => "varchar(32)", "not null" => "1", "default" => ""), + "command" => array("type" => "varbinary(32)", "not null" => "1", "default" => ""), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( @@ -1330,7 +1330,7 @@ function db_definition($charset) { $database["session"] = array( "fields" => array( "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "sid" => array("type" => "varbinary(255)", "not null" => "1", "default" => ""), "data" => array("type" => "text"), "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), ), From a6d7ad07555de5c9b67f96ec38afd418521201a4 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Mon, 26 Dec 2016 02:41:00 +0100 Subject: [PATCH 10/15] Update cache on photo edit only when album name has changed --- mod/photos.php | 15 +++++++++------ view/templates/photo_edit.tpl | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 24325f1cc5..e026944423 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -380,10 +380,11 @@ function photos_post(&$a) { if (($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) { - $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : ''); - $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); - $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); - $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : ''); + $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : ''); + $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); + $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); + $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : ''); + $origaname = ((x($_POST,'origaname')) ? notags(trim($_POST['origaname'])) : ''); $str_group_allow = perms2str($_POST['group_allow']); $str_contact_allow = perms2str($_POST['contact_allow']); $str_group_deny = perms2str($_POST['group_deny']); @@ -467,8 +468,10 @@ function photos_post(&$a) { dbesc($resource_id), intval($page_owner_uid) ); - // Update the photo albums cache - photo_albums($page_owner_uid, true); + // Update the photo albums cache if album name was changed + if ($albname !== $origaname) { + photo_albums($page_owner_uid, true); + } } /* Don't make the item visible if the only change was the album name */ diff --git a/view/templates/photo_edit.tpl b/view/templates/photo_edit.tpl index d435f7f325..714a97dce5 100644 --- a/view/templates/photo_edit.tpl +++ b/view/templates/photo_edit.tpl @@ -3,6 +3,7 @@
+ {{include file="field_input.tpl" field=$album}} {{include file="field_input.tpl" field=$caption}} From 38fed9a77b20e163a757a8bc183aaa030e913fc6 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 26 Dec 2016 06:02:14 +0000 Subject: [PATCH 11/15] We should increase the database version as well ... --- boot.php | 2 +- update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index aab3498146..cad5e0698e 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1209 ); +define ( 'DB_UPDATE_VERSION', 1210 ); /** * @brief Constant with a HTML line break. diff --git a/update.php b/update.php index 7aec2ec2b8..948e10f27e 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Mon, 26 Dec 2016 23:44:21 +0000 Subject: [PATCH 12/15] updated database.sql --- database.sql | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/database.sql b/database.sql index 7cbe4858a8..3eb70b4511 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.5.1-dev (Asparagus) --- DB_UPDATE_VERSION 1208 +-- DB_UPDATE_VERSION 1210 -- ------------------------------------------ @@ -54,11 +54,11 @@ CREATE TABLE IF NOT EXISTS `auth_codes` ( -- TABLE cache -- CREATE TABLE IF NOT EXISTS `cache` ( - `k` varchar(255) NOT NULL, + `k` varbinary(255) NOT NULL, `v` text, `expire_mode` int(11) NOT NULL DEFAULT 0, `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY(`k`(191)), + PRIMARY KEY(`k`), INDEX `updated` (`updated`), INDEX `expire_mode_updated` (`expire_mode`,`updated`) ) DEFAULT CHARSET=utf8mb4; @@ -94,11 +94,11 @@ CREATE TABLE IF NOT EXISTS `clients` ( -- CREATE TABLE IF NOT EXISTS `config` ( `id` int(10) unsigned NOT NULL auto_increment, - `cat` varchar(255) NOT NULL DEFAULT '', - `k` varchar(255) NOT NULL DEFAULT '', + `cat` varbinary(255) NOT NULL DEFAULT '', + `k` varbinary(255) NOT NULL DEFAULT '', `v` text, PRIMARY KEY(`id`), - UNIQUE INDEX `cat_k` (`cat`(30),`k`(30)) + UNIQUE INDEX `cat_k` (`cat`,`k`) ) DEFAULT CHARSET=utf8mb4; -- @@ -200,7 +200,7 @@ CREATE TABLE IF NOT EXISTS `conv` ( -- CREATE TABLE IF NOT EXISTS `deliverq` ( `id` int(10) unsigned NOT NULL auto_increment, - `cmd` varchar(32) NOT NULL DEFAULT '', + `cmd` varbinary(32) NOT NULL DEFAULT '', `item` int(11) NOT NULL DEFAULT 0, `contact` int(11) NOT NULL DEFAULT 0, PRIMARY KEY(`id`), @@ -682,10 +682,10 @@ CREATE TABLE IF NOT EXISTS `notify-threads` ( -- TABLE oembed -- CREATE TABLE IF NOT EXISTS `oembed` ( - `url` varchar(255) NOT NULL, + `url` varbinary(255) NOT NULL, `content` text, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY(`url`(191)), + PRIMARY KEY(`url`), INDEX `created` (`created`) ) DEFAULT CHARSET=utf8mb4; @@ -693,12 +693,12 @@ CREATE TABLE IF NOT EXISTS `oembed` ( -- TABLE parsed_url -- CREATE TABLE IF NOT EXISTS `parsed_url` ( - `url` varchar(255) NOT NULL, + `url` varbinary(255) NOT NULL, `guessing` tinyint(1) NOT NULL DEFAULT 0, `oembed` tinyint(1) NOT NULL DEFAULT 0, `content` text, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY(`url`(191),`guessing`,`oembed`), + PRIMARY KEY(`url`,`guessing`,`oembed`), INDEX `created` (`created`) ) DEFAULT CHARSET=utf8mb4; @@ -708,11 +708,11 @@ CREATE TABLE IF NOT EXISTS `parsed_url` ( CREATE TABLE IF NOT EXISTS `pconfig` ( `id` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL DEFAULT 0, - `cat` varchar(255) NOT NULL DEFAULT '', - `k` varchar(255) NOT NULL DEFAULT '', + `cat` varbinary(255) NOT NULL DEFAULT '', + `k` varbinary(255) NOT NULL DEFAULT '', `v` mediumtext, PRIMARY KEY(`id`), - UNIQUE INDEX `uid_cat_k` (`uid`,`cat`(30),`k`(30)) + UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`) ) DEFAULT CHARSET=utf8mb4; -- @@ -786,7 +786,7 @@ CREATE TABLE IF NOT EXISTS `poll_result` ( -- CREATE TABLE IF NOT EXISTS `process` ( `pid` int(10) unsigned NOT NULL, - `command` varchar(32) NOT NULL DEFAULT '', + `command` varbinary(32) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(`pid`), INDEX `command` (`command`) @@ -920,7 +920,7 @@ CREATE TABLE IF NOT EXISTS `search` ( -- CREATE TABLE IF NOT EXISTS `session` ( `id` bigint(20) unsigned NOT NULL auto_increment, - `sid` varchar(255) NOT NULL DEFAULT '', + `sid` varbinary(255) NOT NULL DEFAULT '', `data` text, `expire` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`id`), From 8e2fc0f8a97a6f2cf7573d604a33d0685982daa5 Mon Sep 17 00:00:00 2001 From: Johannes Schwab Date: Tue, 27 Dec 2016 15:47:53 +0100 Subject: [PATCH 13/15] Fix test for static calls with PHP 7 --- boot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index aab3498146..db03f9f952 100644 --- a/boot.php +++ b/boot.php @@ -809,7 +809,7 @@ class App { function get_baseurl($ssl = false) { // Is the function called statically? - if (!is_object($this)) { + if (!(isset($this) && get_class($this) == __CLASS__)) { return self::$a->get_baseurl($ssl); } @@ -1053,7 +1053,7 @@ class App { function remove_baseurl($orig_url){ // Is the function called statically? - if (!is_object($this)) { + if (!(isset($this) && get_class($this) == __CLASS__)) { return(self::$a->remove_baseurl($orig_url)); } From 236c7805a4ebb1beca89211454644cd6d0f50da1 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 27 Dec 2016 17:53:59 +0100 Subject: [PATCH 14/15] for the fed stats it is better to have a >= then a = in the query --- mod/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/admin.php b/mod/admin.php index 72412f69b4..841aaa7871 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -285,14 +285,14 @@ function admin_page_federation(&$a) { // get a total count for the platform, the name and version of the // highest version and the protocol tpe $c = qu('SELECT COUNT(*) AS `total`, `platform`, `network`, `version` FROM `gserver` - WHERE `platform` LIKE "%s" AND `last_contact` > `last_failure` + WHERE `platform` LIKE "%s" AND `last_contact` >= `last_failure` ORDER BY `version` ASC;', $p); $total = $total + $c[0]['total']; // what versions for that platform do we know at all? // again only the active nodes $v = qu('SELECT COUNT(*) AS `total`, `version` FROM `gserver` - WHERE `last_contact` > `last_failure` AND `platform` LIKE "%s" + WHERE `last_contact` >= `last_failure` AND `platform` LIKE "%s" GROUP BY `version` ORDER BY `version`;', $p); From aab21838a4d98bd182179085961bb5bdd5654286 Mon Sep 17 00:00:00 2001 From: Johannes Schwab Date: Tue, 27 Dec 2016 19:07:57 +0100 Subject: [PATCH 15/15] Missing self befor class constants --- include/ostatus.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/include/ostatus.php b/include/ostatus.php index f9911bfaab..f00f682978 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -596,21 +596,25 @@ class ostatus { $last = get_config('system','ostatus_last_poll'); $poll_interval = intval(get_config('system','ostatus_poll_interval')); - if(! $poll_interval) - $poll_interval = OSTATUS_DEFAULT_POLL_INTERVAL; + if (!$poll_interval) { + $poll_interval = self::OSTATUS_DEFAULT_POLL_INTERVAL; + } // Don't poll if the interval is set negative - if (($poll_interval < 0) AND !$override) + if (($poll_interval < 0) AND !$override) { return; + } if (!$mentions) { $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe')); - if (!$poll_timeframe) - $poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME; + if (!$poll_timeframe) { + $poll_timeframe = self::OSTATUS_DEFAULT_POLL_TIMEFRAME; + } } else { $poll_timeframe = intval(get_config('system','ostatus_poll_timeframe')); - if (!$poll_timeframe) - $poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS; + if (!$poll_timeframe) { + $poll_timeframe = self::OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS; + } } @@ -626,15 +630,16 @@ class ostatus { $start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60)); - if ($mentions) + if ($mentions) { $conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term` STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid` WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention` GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start)); - else + } else { $conversations = q("SELECT `oid`, `url`, `uid` FROM `term` WHERE `type` = 7 AND `term` > '%s' GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start)); + } foreach ($conversations AS $conversation) { self::completion($conversation['url'], $conversation['uid']);