1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 09:14:58 +02:00

Some updates to touch support per issue #84, plus a few other minor things that got bundled in

This commit is contained in:
Ryan Cramer
2016-11-30 13:18:14 -05:00
parent 6a3789d892
commit b8e51db176
18 changed files with 115 additions and 43 deletions

View File

@@ -275,7 +275,12 @@ $config->sessionFingerprint = 1;
$config->sessionCookieSecure = 1;
/**
* Cookie domain
* Cookie domain for sessions
*
* Enables a session to traverse multiple subdomains.
* Specify a string with domain or NULL to disable (default/recommended).
*
* @var string|null
*
*/
$config->sessionCookieDomain = null;
@@ -773,9 +778,7 @@ $config->dbCharset = 'utf8';
/**
* Database engine
*
* MyISAM is the recommended value, but you may also use InnoDB (experimental).
*
* Note that use of 'InnoDB' is currently experimental. Avoid changing this after install.
* May be 'InnoDB' or 'MyISAM'. Avoid changing this after install.
*
*/
$config->dbEngine = 'MyISAM';
@@ -870,9 +873,21 @@ $config->dbSqlModes = array(
"5.7.0" => "remove:STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY"
);
/**
* A key=>value array of any additional driver-specific connection options.
*
* This is the
*
* @var array
*
*/
$config->dbOptions = array();
/**
* Optional DB socket config for sites that need it (for most you should exclude this)
*
* @var string
*
*/
$config->dbSocket = '';

View File

@@ -52,6 +52,7 @@
* @property string $sessionName Default session name to use (default='wire') #pw-group-session
* @property string $sessionNameSecure Session name when on HTTPS. Used when the sessionCookieSecure option is enabled (default). When blank (default), it will assume sessionName + 's'. #pw-group-session
* @property bool|int $sessionCookieSecure Use secure cookies when on HTTPS? When enabled, separate sessions will be maintained for HTTP vs. HTTPS. Good for security but tradeoff is login session may be lost when switching (default=1 or true). #pw-group-session
* @property null|string $sessionCookieDomain Domain to use for sessions, which enables a session to work across subdomains, or NULL to disable (default/recommended). #pw-group-session
* @property bool|callable $sessionAllow Are sessions allowed? Typically boolean true, unless provided a callable function that returns boolean. See /wire/config.php for an example. #pw-group-session
* @property int $sessionExpireSeconds How many seconds of inactivity before session expires? #pw-group-session
* @property bool $sessionChallenge Should login sessions have a challenge key? (for extra security, recommended) #pw-group-session
@@ -93,12 +94,14 @@
* @property string $dbUser Database user #pw-group-database
* @property string $dbPass Database password #pw-group-database
* @property string $dbPort Database port (default=3306) #pw-group-database
* @property string $dbCharset Default is 'utf8' #pw-group-database
* @property string $dbCharset Default is 'utf8' but 'utf8mb4' is also supported. #pw-group-database
* @property string $dbEngine Database engine (MyISAM or InnoDB) #pw-group-database
* @property string $dbSocket Optional DB socket config for sites that need it. #pw-group-database
* @property bool $dbCache Whether to allow MySQL query caching. #pw-group-database
* @property bool $dbLowercaseTables Force any created field_* tables to be lowercase. #pw-group-database
* @property string $dbEngine Database engine (MyISAM or InnoDB) #pw-group-database
* @property string $dbPath MySQL database exec path (Path to mysqldump) #pw-group-database
* @property array $dbOptions Any additional driver options to pass as $options argument to "new PDO(...)". #pw-group-database
* @property array $dbSqlModes Set or adjust SQL mode per MySQL version, where array keys are MySQL version and values are SQL mode command(s). #pw-group-database
* @property int $dbQueryLogMax Maximum number of queries WireDatabasePDO will log in memory, when debug mode is enabled (default=1000). #pw-group-database
* @property string $dbInitCommand Database init command, for PDO::MYSQL_ATTR_INIT_COMMAND. Note placeholder {charset} gets replaced with $config->dbCharset. #pw-group-database
* $property array $dbSqlModes Set, add or remove SQL mode based on MySQL version. See default in /wire/config.php for details. #pw-group-database

View File

@@ -76,13 +76,13 @@
*
* Methods added by PagePermissions.module:
* ----------------------------------------
* @method bool viewable($field = '') Returns true if the page (and optionally field) is viewable by the current user, false if not. #pw-group-access
* @method bool editable($field = '') Returns true if the page (and optionally field) is editable by the current user, false if not. #pw-group-access
* @method bool viewable($field = '', $checkTemplateFile = true) Returns true if the page (and optionally field) is viewable by the current user, false if not. #pw-group-access
* @method bool editable($field = '', $checkPageEditable = true) Returns true if the page (and optionally field) is editable by the current user, false if not. #pw-group-access
* @method bool publishable() Returns true if the page is publishable by the current user, false if not. #pw-group-access
* @method bool listable() Returns true if the page is listable by the current user, false if not. #pw-group-access
* @method bool deleteable() Returns true if the page is deleteable by the current user, false if not. #pw-group-access
* @method bool deletable() Alias of deleteable(). #pw-group-access
* @method bool trashable() Returns true if the page is trashable by the current user, false if not. #pw-group-access
* @method bool trashable($orDeleteable = false) Returns true if the page is trashable by the current user, false if not. #pw-group-access
* @method bool addable($pageToAdd = null) Returns true if the current user can add children to the page, false if not. Optionally specify the page to be added for additional access checking. #pw-group-access
* @method bool moveable($newParent = null) Returns true if the current user can move this page. Optionally specify the new parent to check if the page is moveable to that parent. #pw-group-access
* @method bool sortable() Returns true if the current user can change the sort order of the current page (within the same parent). #pw-group-access

View File

@@ -107,6 +107,8 @@ class WireDatabasePDO extends Wire implements WireDatabase {
$name = $config->dbName;
$socket = $config->dbSocket;
$charset = $config->dbCharset;
$options = $config->dbOptions;
$initCommand = str_replace('{charset}', $charset, $config->dbInitCommand);
if($socket) {
@@ -118,13 +120,17 @@ class WireDatabasePDO extends Wire implements WireDatabase {
if($port) $dsn .= ";port=$port";
}
$driver_options = array(
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
);
if(!is_array($options)) $options = array();
if($initCommand) $driver_options[\PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
if(!isset($options[\PDO::ATTR_ERRMODE])) {
$options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
}
$database = new WireDatabasePDO($dsn, $username, $password, $driver_options);
if($initCommand && !isset($options[\PDO::MYSQL_ATTR_INIT_COMMAND])) {
$options[\PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
}
$database = new WireDatabasePDO($dsn, $username, $password, $options);
$database->setDebugMode($config->debug);
$config->wire($database);
$database->_init();

View File

@@ -66,10 +66,9 @@ class AdminThemeDefaultHelpers extends WireData {
$out = '';
$loggedin = $this->wire('user')->isLoggedin();
$touch = $this->wire('session')->get('touch');
$separator = "<i class='fa fa-angle-right'></i>";
if(!$touch && $loggedin && $this->className() == 'AdminThemeDefaultHelpers') {
if($loggedin && $this->className() == 'AdminThemeDefaultHelpers') {
if($this->wire('config')->debug && $this->wire('user')->isSuperuser()) {
$label = __('Debug Mode Tools', '/wire/templates-admin/debug.inc');

View File

@@ -80,7 +80,7 @@ class AdminThemeRenoHelpers extends AdminThemeDefaultHelpers {
$avatarField != '' ? $imgField = $user->get($avatarField) : $imgField = '';
$avatar = "<i class='fa $adminTheme->profile'></i>";
if($user->isLoggedin() && !$this->session->get('touch')) {
if($user->isLoggedin()) {
if($config->debug && $user->isSuperuser()) {
$debugLabel = __('Debug Mode Tools', '/wire/templates-admin/debug.inc');
$items[] = array(

View File

@@ -17,12 +17,16 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Page that owns these comments, required to use the renderForm() or getCommentForm() methods.
*
* @var Page|null
*
*/
protected $page = null;
/**
* Field object associated with this CommentArray
*
* @var Field|null
*
*/
protected $field = null;
@@ -59,6 +63,9 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Per the WireArray interface, is the item a Comment
*
* @param Wire|Comment $item
* @return bool
*
*/
public function isValidItem($item) {
if($item instanceof Comment) {
@@ -80,10 +87,10 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
*/
public function render(array $options = array()) {
$defaultOptions = array(
'useGravatar' => ($this->field ? $this->field->useGravatar : ''),
'useVotes' => ($this->field ? $this->field->useVotes : 0),
'useStars' => ($this->field ? $this->field->useStars : 0),
'depth' => ($this->field ? (int) $this->field->depth : 0),
'useGravatar' => ($this->field ? $this->field->get('useGravatar') : ''),
'useVotes' => ($this->field ? $this->field->get('useVotes') : 0),
'useStars' => ($this->field ? $this->field->get('useStars') : 0),
'depth' => ($this->field ? (int) $this->field->get('depth') : 0),
'dateFormat' => 'relative',
);
$options = array_merge($defaultOptions, $options);
@@ -91,7 +98,14 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
return $commentList->render();
}
/**
* Make a new blank CommentArray setup for the same Page/Field as the one it is called on
*
* @return CommentArray
*
*/
public function makeNew() {
/** @var CommentArray $a */
$a = parent::makeNew();
if($this->page) $a->setPage($this->page);
if($this->field) $a->setField($this->field);
@@ -108,7 +122,7 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
*/
public function renderForm(array $options = array()) {
$defaultOptions = array(
'depth' => ($this->field ? (int) $this->field->depth : 0)
'depth' => ($this->field ? (int) $this->field->get('depth') : 0)
);
$options = array_merge($defaultOptions, $options);
$form = $this->getCommentForm($options);
@@ -129,6 +143,9 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Return instance of CommentList object
*
* @param array $options See CommentList::$options for details
* @return CommentList
*
*/
public function getCommentList(array $options = array()) {
return $this->wire(new CommentList($this, $options));
@@ -150,6 +167,8 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Set the page that these comments are on
*
* @param Page $page
*
*/
public function setPage(Page $page) {
$this->page = $page;
@@ -158,6 +177,8 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Set the Field that these comments are on
*
* @param Field $field
*
*/
public function setField(Field $field) {
$this->field = $field;
@@ -166,6 +187,8 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Get the page that these comments are on
*
* @return Page
*
*/
public function getPage() {
return $this->page;
@@ -174,6 +197,8 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
/**
* Get the Field that these comments are on
*
* @return Field
*
*/
public function getField() {
return $this->field;
@@ -217,7 +242,8 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
*/
public function isIdentical(WireArray $items, $strict = true) {
$isIdentical = parent::isIdentical($items, $strict);
if($isIdentical && $strict) {
if($isIdentical && $strict && $items instanceof CommentArray) {
/** @var CommentArray $items */
if(((string) $this->getPage()) != ((string) $items->getPage())) return false;
if(((string) $this->getField()) != ((string) $items->getField())) return false;
}

View File

@@ -89,7 +89,7 @@ class CommentList extends Wire implements CommentListInterface {
$this->comments = $comments;
$this->page = $comments->getPage();
$this->field = $comments->getField();
$this->options['useStars'] = $this->field->useStars;
$this->options['useStars'] = $this->field->get('useStars');
$this->options = array_merge($this->options, $options);
}
@@ -150,8 +150,10 @@ class CommentList extends Wire implements CommentListInterface {
* It may be used for production, but only if it meets your needs already. Typically you'll want to render the comments
* using your own code in your templates.
*
* @see CommentArray::render()
* @param Comment $comment
* @param int $depth Default=0
* @return string
* @see CommentArray::render()
*
*/
public function renderItem(Comment $comment, $depth = 0) {

View File

@@ -93,6 +93,7 @@ class InputfieldSubmit extends Inputfield {
} else {
$this->removeClass('ui-priority-secondary');
}
return $this;
}
/**
@@ -137,7 +138,7 @@ class InputfieldSubmit extends Inputfield {
*/
protected function renderDropdown() {
if($this->wire('input')->get('modal') || $this->wire('session')->get('touch')) return '';
if($this->wire('input')->get('modal')) return '';
$config = $this->wire('config');
$file = $config->debug ? 'dropdown.js' : 'dropdown.min.js';

View File

@@ -157,8 +157,8 @@ var InputfieldSubmitDropdown = {
*/
init: function(buttonSelector, $dropdownTemplate) {
// don't use dropdowns when on touch device or in modal window
if($('body').hasClass('touch-device') || $('body').hasClass('modal')) {
// don't use dropdowns when in modal window
if($('body').hasClass('modal')) {
$("ul.pw-button-dropdown").hide();
return false;
}

View File

@@ -1 +1 @@
var InputfieldSubmitDropdown={click:function(){var e=$(this);var b=e.attr("href");var f=e.closest(".pw-button-dropdown");var d;if(!f.length){return true}d=f.data("pw-button");if(e.hasClass("pw-button-dropdown-default")){}else{var c=e.attr("data-pw-dropdown-value");var a=f.attr("data-pw-dropdown-input");if(!c){return true}if(a){var g=$(a);if(!g.length){return true}g.val(c)}else{if(b.length>1){return true}}if(d){d.attr("value",c)}}if(!d){return true}$(":input:focus").blur();d.click();return false},dropdownCnt:0,initDropdown:function(e,d){var c=$("<button><i class='fa fa-angle-down'></i></button>").attr("id","pw-dropdown-toggle-"+d.attr("id"));d.after(c);c.button();var h=null;if(e.hasClass("pw-button-dropdown-template")){h=e;e=h.clone();h.hide()}InputfieldSubmitDropdown.dropdownCnt++;var g="pw-button-dropdown-"+InputfieldSubmitDropdown.dropdownCnt;e.addClass("pw-dropdown-menu pw-dropdown-menu-rounded pw-button-dropdown-init "+g);e.data("pw-button",d);var a=d.find(".ui-button-text");var b=$.trim(a.text());var f=a.html();e.find("a").each(function(){var j=$(this);if(h){var i=j.html();if(i.indexOf("%s")>-1){j.html(i.replace("%s",b))}}j.click(InputfieldSubmitDropdown.click)});d.addClass("pw-button-dropdown-main");c.after(e).addClass("pw-dropdown-toggle-click pw-dropdown-toggle pw-button-dropdown-toggle").attr("data-pw-dropdown","."+g);if(d.hasClass("ui-priority-secondary")){c.addClass("ui-priority-secondary")}if(d.hasClass("pw-head-button")){c.addClass("pw-head-button")}c.click(function(){return false}).on("pw-button-dropdown-off",function(){$(this).siblings(".pw-button-dropdown-main").removeClass("pw-button-dropdown-main").addClass("pw-button-dropdown-disabled");$(this).hide()}).on("pw-button-dropdown-on",function(){$(this).siblings(".pw-button-dropdown-disabled").addClass("pw-button-dropdown-main").removeClass("pw-button-dropdown-disabled");$(this).show()})},init:function(b,c){if($("body").hasClass("touch-device")||$("body").hasClass("modal")){$("ul.pw-button-dropdown").hide();return false}var a=(typeof b=="string")?$(b):b;a.each(function(){var d=$(this);if(typeof c!="undefined"){c.addClass("pw-button-dropdown-template");InputfieldSubmitDropdown.initDropdown(c,d)}else{var e=$("#"+$(this).prop("id")+"_dropdown");if(e.length){InputfieldSubmitDropdown.initDropdown(e,d)}}});return true}};
var InputfieldSubmitDropdown={click:function(){var e=$(this);var b=e.attr("href");var f=e.closest(".pw-button-dropdown");var d;if(!f.length){return true}d=f.data("pw-button");if(e.hasClass("pw-button-dropdown-default")){}else{var c=e.attr("data-pw-dropdown-value");var a=f.attr("data-pw-dropdown-input");if(!c){return true}if(a){var g=$(a);if(!g.length){return true}g.val(c)}else{if(b.length>1){return true}}if(d){d.attr("value",c)}}if(!d){return true}$(":input:focus").blur();d.click();return false},dropdownCnt:0,initDropdown:function(e,d){var c=$("<button><i class='fa fa-angle-down'></i></button>").attr("id","pw-dropdown-toggle-"+d.attr("id"));d.after(c);c.button();var h=null;if(e.hasClass("pw-button-dropdown-template")){h=e;e=h.clone();h.hide()}InputfieldSubmitDropdown.dropdownCnt++;var g="pw-button-dropdown-"+InputfieldSubmitDropdown.dropdownCnt;e.addClass("pw-dropdown-menu pw-dropdown-menu-rounded pw-button-dropdown-init "+g);e.data("pw-button",d);var a=d.find(".ui-button-text");var b=$.trim(a.text());var f=a.html();e.find("a").each(function(){var j=$(this);if(h){var i=j.html();if(i.indexOf("%s")>-1){j.html(i.replace("%s",b))}}j.click(InputfieldSubmitDropdown.click)});d.addClass("pw-button-dropdown-main");c.after(e).addClass("pw-dropdown-toggle-click pw-dropdown-toggle pw-button-dropdown-toggle").attr("data-pw-dropdown","."+g);if(d.hasClass("ui-priority-secondary")){c.addClass("ui-priority-secondary")}if(d.hasClass("pw-head-button")){c.addClass("pw-head-button")}c.click(function(){return false}).on("pw-button-dropdown-off",function(){$(this).siblings(".pw-button-dropdown-main").removeClass("pw-button-dropdown-main").addClass("pw-button-dropdown-disabled");$(this).hide()}).on("pw-button-dropdown-on",function(){$(this).siblings(".pw-button-dropdown-disabled").addClass("pw-button-dropdown-main").removeClass("pw-button-dropdown-disabled");$(this).show()})},init:function(b,c){if($("body").hasClass("modal")){$("ul.pw-button-dropdown").hide();return false}var a=(typeof b=="string")?$(b):b;a.each(function(){var d=$(this);if(typeof c!="undefined"){c.addClass("pw-button-dropdown-template");InputfieldSubmitDropdown.initDropdown(c,d)}else{var e=$("#"+$(this).prop("id")+"_dropdown");if(e.length){InputfieldSubmitDropdown.initDropdown(e,d)}}});return true}};

View File

@@ -0,0 +1 @@
$(document).ready(function(){if(window.devicePixelRatio>1){var a=true}else{var b="(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";var a=window.matchMedia&&window.matchMedia(b).matches}$("#login_hidpi").val(a?1:0);var c=(("ontouchstart" in window)||(navigator.MaxTouchPoints>0)||(navigator.msMaxTouchPoints>0));$("#login_touch").val(c?1:0)});

View File

@@ -452,7 +452,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
$out .= $this->form->render();
// buttons with dropdowns
if(!$this->wire('input')->get('modal') && !$this->wire('session')->get('touch') && !count($this->fields)) {
if(!$this->wire('input')->get('modal') && !count($this->fields)) {
$config = $this->wire('config');
$file = $config->debug ? 'dropdown.js' : 'dropdown.min.js';

View File

@@ -129,7 +129,6 @@ $(document).ready(function() {
var ignoreClicks = false;
var isModal = $("body").hasClass("modal");
var isTouch = $("body").hasClass("touch");
$.extend(options, customOptions);
@@ -167,7 +166,7 @@ $(document).ready(function() {
*/
}
if(options.useHoverActions && !$("body").hasClass('touch-device')) {
if(options.useHoverActions) {
$root.addClass('PageListUseHoverActions');
setupHoverActions();
}
@@ -668,7 +667,7 @@ $(document).ready(function() {
else actionName = action.cn; // cn = className
var $a = $("<a></a>").html(action.name).attr('href', action.url);
if(!isModal && !isTouch) {
if(!isModal) {
if(action.cn == 'Edit') {
$a.addClass('pw-modal pw-modal-large pw-modal-longclick');
$a.attr('data-buttons', '#ProcessPageEdit > .Inputfields > .InputfieldSubmit .ui-button');

File diff suppressed because one or more lines are too long

View File

@@ -274,15 +274,35 @@ var ProcessWireAdmin = {
}
function touchClick() {
var touchCnt = $(this).attr('data-touchCnt');
var $lastTouchClickItem = null;
function touchClick(e) {
var $item = $(this);
var touchCnt = $item.attr('data-touchCnt');
if($lastTouchClickItem && $item.attr('id') != $lastTouchClickItem.attr('id')) {
$lastTouchClickItem.attr('data-touchCnt', 0);
}
$lastTouchClickItem = $item;
if(!touchCnt) touchCnt = 0;
touchCnt++;
$(this).attr('data-touchCnt', touchCnt);
if(touchCnt == 2) {
$(this).mouseleave();
$item.attr('data-touchCnt', touchCnt);
if(touchCnt == 2 || ($item.hasClass('pw-has-ajax-items') && !$item.closest('ul').hasClass('topnav'))) {
var href = $item.attr('href');
$item.attr('data-touchCnt', 0);
if(typeof href != "undefined" && href.length > 1) {
return true;
} else {
$item.mouseleave();
}
} else {
$(this).mouseenter();
var datafrom = $item.attr('data-from');
if(typeof datafrom == "undefined") var datafrom = '';
if(datafrom.indexOf('topnav') > -1) {
var from = datafrom.replace('topnav-', '') + '-';
$("a.pw-dropdown-toggle.hover:not('." + from + "')").attr('data-touchCnt', 0).mouseleave();
}
$item.mouseenter();
}
return false;
}
@@ -290,7 +310,7 @@ var ProcessWireAdmin = {
function init() {
if($("body").hasClass('touch-device')) {
$('#topnav').on("click", "a.pw-dropdown-toggle, a.pw-has-items", touchClick);
$(document).on("touchstart", "a.pw-dropdown-toggle, a.pw-has-items", touchClick);
}
$(".pw-dropdown-menu").on("click", "a:not(.pw-modal)", function(e) {

File diff suppressed because one or more lines are too long