1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 09:14:58 +02:00
This commit is contained in:
Ryan Cramer
2022-12-02 08:02:49 -05:00
parent b18ce642ef
commit 56e999dddb
8 changed files with 163 additions and 156 deletions

View File

@@ -21,11 +21,12 @@ function InputfieldPageTableDialog() {
$table.find('tbody').css('overflow', 'visible');
InputfieldPageTableSortable($table);
// restore appearnace of any items marked for deletion
// restore appearance of any items marked for deletion
var deleteIDs = $container.siblings("input.InputfieldPageTableDelete").eq(0).val().split('|');
if(deleteIDs.length) {
for(var n = 0; n < deleteIDs.length; n++) {
var deleteID = deleteIDs[n];
if(!deleteID.length) continue;
$table.find("tr[data-id=" + deleteID + "]")
.addClass('InputfieldPageTableDelete ui-state-error-text ui-state-disabled');
}

View File

@@ -1 +1 @@
function InputfieldPageTableDialog(){var $a=$(this);var url=$a.attr("data-url");var title=$a.attr("data-title");var closeOnSave=true;var $container=$(this).parents(".InputfieldPageTableContainer");var dialogPageID=0;var noclose=parseInt($container.attr("data-noclose"));var modalSettings={close:function(event,ui){if(dialogPageID>0){var ajaxURL=$container.attr("data-url")+"&InputfieldPageTableAdd="+dialogPageID;var sort=$container.siblings(".InputfieldPageTableSort").val();if(typeof sort!="undefined"&&sort.length)ajaxURL+="&InputfieldPageTableSort="+sort.replace(/\|/g,",");$.get(ajaxURL,function(data){$container.html(data);$container.find(".Inputfield").trigger("reloaded",["InputfieldPageTable"]);$container.effect("highlight",500,function(){var $table=$container.find("table");$table.find("tbody").css("overflow","visible");InputfieldPageTableSortable($table);var deleteIDs=$container.siblings("input.InputfieldPageTableDelete").eq(0).val().split("|");if(deleteIDs.length){for(var n=0;n<deleteIDs.length;n++){var deleteID=deleteIDs[n];$table.find("tr[data-id="+deleteID+"]").addClass("InputfieldPageTableDelete ui-state-error-text ui-state-disabled")}}})})}}};var $iframe=pwModalWindow(url,modalSettings,"large");var closeOnSaveReady=false;if($a.is(".InputfieldPageTableAdd"))closeOnSave=false;$iframe.load(function(){var buttons=[];var $icontents=$iframe.contents();var n=0;dialogPageID=$icontents.find("#Inputfield_id").val();$icontents.find("#wrap_Inputfield_template, #wrap_template, #wrap_parent_id").hide();$icontents.find("#_ProcessPageEditDelete, #_ProcessPageEditChildren").hide();closeOnSave=noclose==0&&$icontents.find("#ProcessPageAdd").length==0;if(closeOnSave&&closeOnSaveReady){if($icontents.find(".NoticeError, .NoticeWarning, .ui-state-error").length==0){if(typeof Notifications!="undefined"){var messages=[];$icontents.find(".NoticeMessage").each(function(){messages[messages.length]=$(this).text()});if(messages.length>0)setTimeout(function(){for(var i=0;i<messages.length;i++){Notifications.message(messages[i])}},500)}$iframe.dialog("close");return}else{}}$icontents.find("#content form button.ui-button[type=submit]").each(function(){var $button=$(this);var text=$button.text();var skip=false;for(var i=0;i<buttons.length;i++){if(buttons[i].text==text||text.length<1)skip=true}if(!skip){buttons[n]={text:text,class:$button.is(".ui-priority-secondary")?"ui-priority-secondary":"",click:function(){$button.click();if(closeOnSave)closeOnSaveReady=true;if(!noclose)closeOnSave=true}};n++}$button.hide()});$iframe.setButtons(buttons)});return false}function InputfieldPageTableUpdate($table){var value="";if(!$table.is("tbody"))$table=$table.find("tbody");$table.find("tr").each(function(){var pageID=$(this).attr("data-id");if(value.length>0)value+="|";value+=pageID});var $container=$table.parents(".InputfieldPageTableContainer");var $input=$container.siblings(".InputfieldPageTableSort");$input.val(value)}function InputfieldPageTableSortable($tables){$tables.each(function(){var $table=$(this);if($table.closest(".InputfieldRenderValueMode").length)return;$table.find("tbody").sortable({axis:"y",start:function(event,ui){var widths=[];var n=0;$table.find("thead").find("th").each(function(){widths[n]=$(this).width();n++});n=0;ui.helper.find("td").each(function(){$(this).attr("width",widths[n]);n++})},stop:function(event,ui){InputfieldPageTableUpdate($(this))},update:function(e,ui){$table.closest(".Inputfield").trigger("sorted",[ui.item])}})})}function InputfieldPageTableDelete(){var $row=$(this).closest("tr");$row.toggleClass("InputfieldPageTableDelete ui-state-error-text ui-state-disabled");var ids="";$row.parents("tbody").children("tr").each(function(){var $tr=$(this);var id=$tr.attr("data-id");if($tr.is(".InputfieldPageTableDelete"))ids+=(ids.length>0?"|":"")+id});var $input=$(this).parents(".InputfieldPageTableContainer").siblings("input.InputfieldPageTableDelete");$input.val(ids);return false}$(document).ready(function(){$(document).on("click",".InputfieldPageTableAdd, .InputfieldPageTableEdit",InputfieldPageTableDialog);$(document).on("click","a.InputfieldPageTableDelete",InputfieldPageTableDelete);$(document).on("dblclick",".InputfieldPageTable .AdminDataTable td",function(){$(this).closest("tr").find(".InputfieldPageTableEdit").click()});InputfieldPageTableSortable($(".InputfieldPageTable table"));$(document).on("reloaded",".InputfieldPageTable",function(){InputfieldPageTableSortable($(this).find(".InputfieldPageTableContainer > table"))});$(document).on("click",".InputfieldPageTableOrphansAll",function(){var $checkboxes=$(this).closest(".InputfieldPageTableOrphans").find("input");$checkboxes.prop("checked",$checkboxes.eq(0).is(":checked")?false:true);return false})});
function InputfieldPageTableDialog(){var $a=$(this);var url=$a.attr("data-url");var title=$a.attr("data-title");var closeOnSave=true;var $container=$(this).parents(".InputfieldPageTableContainer");var dialogPageID=0;var noclose=parseInt($container.attr("data-noclose"));var modalSettings={close:function(event,ui){if(dialogPageID>0){var ajaxURL=$container.attr("data-url")+"&InputfieldPageTableAdd="+dialogPageID;var sort=$container.siblings(".InputfieldPageTableSort").val();if(typeof sort!="undefined"&&sort.length)ajaxURL+="&InputfieldPageTableSort="+sort.replace(/\|/g,",");$.get(ajaxURL,function(data){$container.html(data);$container.find(".Inputfield").trigger("reloaded",["InputfieldPageTable"]);$container.effect("highlight",500,function(){var $table=$container.find("table");$table.find("tbody").css("overflow","visible");InputfieldPageTableSortable($table);var deleteIDs=$container.siblings("input.InputfieldPageTableDelete").eq(0).val().split("|");if(deleteIDs.length){for(var n=0;n<deleteIDs.length;n++){var deleteID=deleteIDs[n];if(!deleteID.length)continue;$table.find("tr[data-id="+deleteID+"]").addClass("InputfieldPageTableDelete ui-state-error-text ui-state-disabled")}}})})}}};var $iframe=pwModalWindow(url,modalSettings,"large");var closeOnSaveReady=false;if($a.is(".InputfieldPageTableAdd"))closeOnSave=false;$iframe.load(function(){var buttons=[];var $icontents=$iframe.contents();var n=0;dialogPageID=$icontents.find("#Inputfield_id").val();$icontents.find("#wrap_Inputfield_template, #wrap_template, #wrap_parent_id").hide();$icontents.find("#_ProcessPageEditDelete, #_ProcessPageEditChildren").hide();closeOnSave=noclose==0&&$icontents.find("#ProcessPageAdd").length==0;if(closeOnSave&&closeOnSaveReady){if($icontents.find(".NoticeError, .NoticeWarning, .ui-state-error").length==0){if(typeof Notifications!="undefined"){var messages=[];$icontents.find(".NoticeMessage").each(function(){messages[messages.length]=$(this).text()});if(messages.length>0)setTimeout(function(){for(var i=0;i<messages.length;i++){Notifications.message(messages[i])}},500)}$iframe.dialog("close");return}else{}}$icontents.find("#content form button.ui-button[type=submit]").each(function(){var $button=$(this);var text=$button.text();var skip=false;for(var i=0;i<buttons.length;i++){if(buttons[i].text==text||text.length<1)skip=true}if(!skip){buttons[n]={text:text,class:$button.is(".ui-priority-secondary")?"ui-priority-secondary":"",click:function(){$button.click();if(closeOnSave)closeOnSaveReady=true;if(!noclose)closeOnSave=true}};n++}$button.hide()});$iframe.setButtons(buttons)});return false}function InputfieldPageTableUpdate($table){var value="";if(!$table.is("tbody"))$table=$table.find("tbody");$table.find("tr").each(function(){var pageID=$(this).attr("data-id");if(value.length>0)value+="|";value+=pageID});var $container=$table.parents(".InputfieldPageTableContainer");var $input=$container.siblings(".InputfieldPageTableSort");$input.val(value)}function InputfieldPageTableSortable($tables){$tables.each(function(){var $table=$(this);if($table.closest(".InputfieldRenderValueMode").length)return;$table.find("tbody").sortable({axis:"y",start:function(event,ui){var widths=[];var n=0;$table.find("thead").find("th").each(function(){widths[n]=$(this).width();n++});n=0;ui.helper.find("td").each(function(){$(this).attr("width",widths[n]);n++})},stop:function(event,ui){InputfieldPageTableUpdate($(this))},update:function(e,ui){$table.closest(".Inputfield").trigger("sorted",[ui.item])}})})}function InputfieldPageTableDelete(){var $row=$(this).closest("tr");$row.toggleClass("InputfieldPageTableDelete ui-state-error-text ui-state-disabled");var ids="";$row.parents("tbody").children("tr").each(function(){var $tr=$(this);var id=$tr.attr("data-id");if($tr.is(".InputfieldPageTableDelete"))ids+=(ids.length>0?"|":"")+id});var $input=$(this).parents(".InputfieldPageTableContainer").siblings("input.InputfieldPageTableDelete");$input.val(ids);return false}$(document).ready(function(){$(document).on("click",".InputfieldPageTableAdd, .InputfieldPageTableEdit",InputfieldPageTableDialog);$(document).on("click","a.InputfieldPageTableDelete",InputfieldPageTableDelete);$(document).on("dblclick",".InputfieldPageTable .AdminDataTable td",function(){$(this).closest("tr").find(".InputfieldPageTableEdit").click()});InputfieldPageTableSortable($(".InputfieldPageTable table"));$(document).on("reloaded",".InputfieldPageTable",function(){InputfieldPageTableSortable($(this).find(".InputfieldPageTableContainer > table"))});$(document).on("click",".InputfieldPageTableOrphansAll",function(){var $checkboxes=$(this).closest(".InputfieldPageTableOrphans").find("input");$checkboxes.prop("checked",$checkboxes.eq(0).is(":checked")?false:true);return false})});

View File

@@ -1,148 +1,140 @@
/**
* jQuery Longclick Event
* ======================
* Press & hold mouse button "long click" special event for jQuery 1.4.x
*
* @license Longclick Event
* Copyright (c) 2010 Petr Vostrel (http://petr.vostrel.cz/)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Version: 0.3.2
* Updated: 2010-06-22
*
*/
(function($){
/*
`.click( duration, handler )`
* Simply supply `duration` to the well-known `.click` method and you have a *long click*.
* This method is a shortcut for `.bind("longclick", handler)`.
* Returns *jQuery*.
*/
var
$_fn_click= $.fn.click
$.fn.click= function click(duration, handler){
/* Shortcircuit ordinary click calls */
if (!handler) return $_fn_click.apply(this, arguments)
/* Bind long click */
return $(this).data(_duration_, duration || null).bind(type, handler)
}
/*
`.longclick( [ duration ], [ handler ] )`
* If supplied, optional custom `duration` is used for target element(s).
* This method is a shortcut for `.click(duration, handler)` when at least `handler` is supplied
and for `.trigger("longclick")` if called without arguments.
* Returns *jQuery*.
*/
$.fn.longclick= function longclick(){
var
args= [].splice.call(arguments, 0),
handler= args.pop(),
duration= args.pop(),
$this= $(this).data(_duration_, duration || null)
return handler ? $this.click(duration, handler) : $this.trigger(type)
}
/*
Configuration
*/
$.longclick= {
/*
* For how long (in milliseconds) mouse button must be pressed down (or touched) stationery
to qualify as a *long click*.
* False value results in using the configured default.
* Default `duration` is **500** and is stored in `jQuery.longclick.duration` variable.
*/
duration: 600
}
/*
Bindings
*/
$.event.special.longclick= {
setup: function(data, namespaces){
if (!(/iphone|ipad|ipod/i).test(navigator.userAgent)){
/* normal technique for standard mouse-based interaction */
$(this)
.bind(_mousedown_, schedule)
.bind([_mousemove_, _mouseup_, _mouseout_, _contextmenu_].join(' '), annul)
.bind(_click_, click)
}else{
/* and special handling for touch-based interaction on iPhone-compatibile devices */
touch_enabled(this)
.bind(_touchstart_, schedule)
.bind([_touchend_, _touchmove_, _touchcancel_].join(' '), annul)
.bind(_click_, click)
.css({ WebkitUserSelect: 'none' })
}
},
teardown: function(namespaces){
$(this).unbind(namespace)
}
}
/*
Commit subset of touch events to trigger jQuery events of same names
*/
function touch_enabled(element){
$.each('touchstart touchmove touchend touchcancel'.split(/ /), function bind(ix, it){
element.addEventListener(it, function trigger_jquery_event(event){ $(element).trigger(it) }, false);
});
return $(element);
}
/*
Handlers
*/
function schedule(event){
/* Check the timer isn't already running and drop if so */
if ($(this).data(_timer_)) return;
/* Catch in closure the `this` reference and `arguments` for later */
var
element= this,
args= arguments
/* Flag as "not fired" and schedule the trigger */
$(this)
.data(_fired_, false)
.data(_timer_, setTimeout(scheduled, $(this).data(_duration_) || $.longclick.duration))
function scheduled(){
/* Flag as "fired" and rejoin the default event flow */
$(element).data(_fired_, true)
event.type= type
jQuery.event.handle.apply(element, args)
//jQuery.event.dispatch.apply(element,args);
}
}
function annul(event){
/* Annul the scheduled trigger */
$(this).data(_timer_, clearTimeout($(this).data(_timer_)) || null)
}
function click(event){
/* Prevent `click` event to be fired after button release once `longclick` was fired */
if ($(this).data(_fired_)) return event.stopImmediatePropagation() || false
}
/*
Frequent primitives and shortcuts
*/
var
type= 'longclick',
namespace= '.' + type,
/* Event strings */
_mousedown_= 'mousedown'+namespace, _click_= 'click'+namespace,
_mousemove_= 'mousemove'+namespace, _mouseup_= 'mouseup'+namespace,
_mouseout_= 'mouseout'+namespace, _contextmenu_= 'contextmenu'+namespace,
_touchstart_= 'touchstart'+namespace, _touchend_= 'touchend'+namespace,
_touchmove_= 'touchmove'+namespace, _touchcancel_= 'touchcancel'+namespace,
/* Storage keys */
_duration_= 'duration'+namespace, _timer_= 'timer'+namespace, _fired_= 'fired'+namespace
})(jQuery);
/**
* jQuery Longclick Event
* ======================
* Press & hold mouse button "long click" special event for jQuery 1.4.x
*
* @license Longclick Event
* Copyright (c) 2014 Pascal GANAYE
* Largely based from from a work Petr Vostrel (http://petr.vostrel.cz/)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Version: 0.4.0
* Updated: 2014-10-13
*/
(function ($) {
/** `.longclick([ handler ], [ duration ])`
* If supplied, optional custom `duration` is used for target element(s).
* This method is a shortcut for `.trigger("longclick")` if called without arguments.
* Returns *jQuery*.
*/
$.fn.longclick = function longclick() {
var handler = arguments[0],
duration = arguments[1],
$this = $(this).data(_duration_, duration || null);
/* Bind long click */
return handler ? $this.bind(type, handler) : $this.trigger(type);
};
/**
* Configuration
*/
$.longclick = {
/**
* For how long (in milliseconds) mouse button must be pressed down (or touched) stationery
* to qualify as a *long click*.
* False value results in using the configured default.
* Default `duration` is **600** and is stored in `jQuery.longclick.duration` variable.
*/
duration: 600
};
/**
* Bindings
*/
$.event.special.longclick = {
setup: function (data, namespaces) {
if (!(/iphone|ipad|ipod/i).test(navigator.userAgent)) {
/* normal technique for standard mouse-based interaction */
$(this)
.bind(_mousedown_, schedule)
.bind([_mouseup_, _mouseout_, _contextmenu_].join(' '), cancel)
.bind(_click_, click);
} else {
/* and special handling for touch-based interaction on iPhone-compatibile devices */
touch_enabled(this)
.bind(_touchstart_, schedule)
.bind([_touchend_, _touchcancel_].join(' '), cancel)
.bind(_click_, click)
.css({WebkitUserSelect: 'none'});
}
},
teardown: function (namespaces) {
$(this).unbind(namespace);
}
};
/**
* Commit subset of touch events to trigger jQuery events of same names
*/
function touch_enabled(element) {
$.each('touchstart touchend touchcancel'.split(/ /), function bind(ix, it) {
element.addEventListener(it, function trigger_jquery_event(event) {
$(element).trigger(it);
}, false);
});
return $(element);
}
/**
* Handlers
*/
function schedule(event) {
/* Check the timer isn't already running and drop if so */
if ($(this).data(_timer_)) return;
/* Catch in closure the `this` reference and `arguments` for later */
var element = this;
var args = arguments;
function scheduled() {
/* Flag as "fired" and rejoin the default event flow */
$(element).data(_fired_, true)
.data(_timer_, null);
event.type = type;
var f = (jQuery.event.dispatch || jQuery.event.handle);
f.apply(element, args);
}
/* Flag as "not fired" and schedule the trigger */
$(this)
.data(_fired_, false)
.data(_timer_, setTimeout(scheduled, $(this).data(_duration_) || $.longclick.duration));
}
function cancel(event) {
var timer = $(this).data(_timer_);
if (timer) {
/* cancel the scheduled trigger */
$(this).data(_timer_, clearTimeout(timer) || null);
}
}
function click(event) {
/* Prevent `click` event to be fired after button release once `longclick` was fired */
if ($(this).data(_fired_)) return event.stopImmediatePropagation() || false;
}
/*
* Frequent primitives and shortcuts
*/
var type = 'longclick',
namespace = '.' + type,
/* Event strings */
_mousedown_ = 'mousedown' + namespace,
_click_ = 'click' + namespace,
_mouseup_ = 'mouseup' + namespace,
_mouseout_ = 'mouseout' + namespace,
_contextmenu_ = 'contextmenu' + namespace,
_touchstart_ = 'touchstart' + namespace,
_touchend_ = 'touchend' + namespace,
_touchcancel_ = 'touchcancel' + namespace,
/* Storage keys */
_duration_ = 'duration' + namespace,
_timer_ = 'timer' + namespace,
_fired_ = 'fired' + namespace;
})(jQuery);

View File

@@ -1 +1,15 @@
(function(f){var l=f.fn.click;f.fn.click=function q(x,w){if(!w){return l.apply(this,arguments)}return f(this).data(t,x||null).bind(b,w)};f.fn.longclick=function n(){var w=[].splice.call(arguments,0),x=w.pop(),z=w.pop(),y=f(this).data(t,z||null);return x?y.click(z,x):y.trigger(b)};f.longclick={duration:600};f.event.special.longclick={setup:function(x,w){if(!(/iphone|ipad|ipod/i).test(navigator.userAgent)){f(this).bind(d,s).bind([a,c,h,i].join(" "),o).bind(v,q)}else{j(this).bind(r,s).bind([e,u,p].join(" "),o).bind(v,q).css({WebkitUserSelect:"none"})}},teardown:function(w){f(this).unbind(m)}};function j(w){f.each("touchstart touchmove touchend touchcancel".split(/ /),function x(y,z){w.addEventListener(z,function A(B){f(w).trigger(z)},false)});return f(w)}function s(y){if(f(this).data(g)){return}var x=this,w=arguments;f(this).data(k,false).data(g,setTimeout(z,f(this).data(t)||f.longclick.duration));function z(){f(x).data(k,true);y.type=b;jQuery.event.handle.apply(x,w)}}function o(w){f(this).data(g,clearTimeout(f(this).data(g))||null)}function q(w){if(f(this).data(k)){return w.stopImmediatePropagation()||false}}var b="longclick",m="."+b,d="mousedown"+m,v="click"+m,a="mousemove"+m,c="mouseup"+m,h="mouseout"+m,i="contextmenu"+m,r="touchstart"+m,e="touchend"+m,u="touchmove"+m,p="touchcancel"+m,t="duration"+m,g="timer"+m,k="fired"+m})(jQuery);
/**
* jQuery Longclick Event
* ======================
* Press & hold mouse button "long click" special event for jQuery 1.4.x
*
* @license Longclick Event
* Copyright (c) 2014 Pascal GANAYE
* Largely based from from a work Petr Vostrel (http://petr.vostrel.cz/)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Version: 0.4.0
* Updated: 2014-10-13
*/
!function(t){function n(n){return t.each("touchstart touchend touchcancel".split(/ /),function(i,e){n.addEventListener(e,function(i){t(n).trigger(e)},!1)}),t(n)}function i(n){if(!t(this).data(b)){var i=this,e=arguments;t(this).data(m,!1).data(b,setTimeout(function(){t(i).data(m,!0).data(b,null),n.type=o,(jQuery.event.dispatch||jQuery.event.handle).apply(i,e)},t(this).data(g)||t.longclick.duration))}}function e(n){var i=t(this).data(b);i&&t(this).data(b,clearTimeout(i)||null)}function a(n){if(t(this).data(m))return n.stopImmediatePropagation()||!1}t.fn.longclick=function(){var n=arguments[0],i=arguments[1],e=t(this).data(g,i||null);return n?e.bind(o,n):e.trigger(o)},t.longclick={duration:600},t.event.special.longclick={setup:function(o,c){/iphone|ipad|ipod/i.test(navigator.userAgent)?n(this).bind(h,i).bind([f,p].join(" "),e).bind(d,a).css({WebkitUserSelect:"none"}):t(this).bind(u,i).bind([r,s,l].join(" "),e).bind(d,a)},teardown:function(n){t(this).unbind(c)}};var o="longclick",c="."+o,u="mousedown"+c,d="click"+c,r="mouseup"+c,s="mouseout"+c,l="contextmenu"+c,h="touchstart"+c,f="touchend"+c,p="touchcancel"+c,g="duration"+c,b="timer"+c,m="fired"+c}(jQuery);

View File

@@ -224,7 +224,7 @@ function pwModalWindow(href, options, size) {
$iframe.dialog(settings);
$iframe.data('settings', settings);
$iframe.load(function() {
$iframe.on('load', function() {
if(typeof settings.title == "undefined" || !settings.title) {
var title = jQuery('<textarea />').text($iframe.contents().find('title').text()).html();
$iframe.dialog('option', 'title', title);
@@ -358,7 +358,7 @@ function pwModalOpenEvent(e) {
$a.removeClass('ui-state-active');
}, 500);
$iframe.load(function() {
$iframe.on('load', function() {
var buttons = [];
var $icontents = $iframe.contents();

File diff suppressed because one or more lines are too long

View File

@@ -310,7 +310,7 @@ var ProcessWireAdmin = {
if(!dropdownPositionsMonitored && data.list.length > 10) {
dropdownPositionsMonitored = true;
setupDropdownHover = true;
$(document).on('hover', 'ul.pw-dropdown-menu a', function() {
$(document).on('mouseenter', 'ul.pw-dropdown-menu a', function() {
hoverDropdownAjaxItem($(this));
});
}

File diff suppressed because one or more lines are too long