diff --git a/wire/core/AdminTheme.php b/wire/core/AdminTheme.php index 5e82906d..951960e0 100644 --- a/wire/core/AdminTheme.php +++ b/wire/core/AdminTheme.php @@ -98,6 +98,8 @@ abstract class AdminTheme extends WireData implements Module { * Initialize the admin theme systme and determine which admin theme should be used * * All admin themes must call this init() method to register themselves. + * + * Note: this should be called after API ready. * */ public function init() { @@ -116,6 +118,11 @@ abstract class AdminTheme extends WireData implements Module { // if admin theme has already been set, then no need to continue if($this->wire('adminTheme')) return; + /** @var Config $config */ + $config = $this->wire('config'); + /** @var Session $session */ + $session = $this->wire('session'); + /** @var string $adminTheme */ $adminTheme = $this->wire('user')->admin_theme; if($adminTheme) { @@ -129,19 +136,20 @@ abstract class AdminTheme extends WireData implements Module { } // adjust $config adminThumbOptions[scale] for auto detect when requested - $o = $this->wire('config')->adminThumbOptions; + $o = $config->adminThumbOptions; if($o && isset($o['scale']) && $o['scale'] === 1) { - $o['scale'] = $this->wire('session')->hidpi ? 0.5 : 1.0; - $this->wire('config')->adminThumbOptions = $o; + $o['scale'] = $session->hidpi ? 0.5 : 1.0; + $config->adminThumbOptions = $o; } - $this->config->js('modals', $this->config->modals); + $config->js('modals', $config->modals); + + if($session->hidpi) $this->addBodyClass('hidpi-device'); + if($session->touch) $this->addBodyClass('touch-device'); - if($this->wire('session')->hidpi) $this->addBodyClass('hidpi-device'); - if($this->wire('session')->touch) $this->addBodyClass('touch-device'); $this->addBodyClass($this->className()); } - + public function get($key) { if($key == 'version') return $this->version; return parent::get($key); diff --git a/wire/core/AdminThemeFramework.php b/wire/core/AdminThemeFramework.php index 45d0a4e9..ca9dba3d 100644 --- a/wire/core/AdminThemeFramework.php +++ b/wire/core/AdminThemeFramework.php @@ -84,6 +84,8 @@ abstract class AdminThemeFramework extends AdminTheme { /** * Initialize and attach hooks + * + * Note: descending classes should call this after API ready * */ public function init() { @@ -98,13 +100,32 @@ abstract class AdminThemeFramework extends AdminTheme { $this->isLoggedIn = $user->isLoggedin(); $this->isSuperuser = $this->isLoggedIn && $user->isSuperuser(); $this->isEditor = $this->isLoggedIn && ($this->isSuperuser || $user->hasPermission('page-edit')); + $this->includeInitFile(); $modal = $this->wire('input')->get('modal'); if($modal) $this->isModal = $modal == 'inline' ? 'inline' : true; // test notices when requested - if($this->wire('input')->get('test_notices')) $this->testNotices(); + if($this->wire('input')->get('test_notices') && $this->isLoggedIn) $this->testNotices(); } + + /** + * Include the admin theme init file + * + */ + public function includeInitFile() { + $config = $this->wire('config'); + $initFile = $config->paths->adminTemplates . 'init.php'; + if(file_exists($initFile)) { + if(strpos($initFile, $config->paths->site) === 0) { + // admin themes in /site/modules/ may be compiled + $initFile = $this->wire('files')->compile($initFile); + } + /** @noinspection PhpIncludeInspection */ + include_once($initFile); + } + } + /** * Perform a translation, based on text from shared admin file: /wire/templates-admin/default.php @@ -584,10 +605,12 @@ abstract class AdminThemeFramework extends AdminTheme { // if(!count($notices)) return ''; + /* if($this->isLoggedIn && $this->wire('modules')->isInstalled('SystemNotifications')) { $systemNotifications = $this->wire('modules')->get('SystemNotifications'); if(!$systemNotifications->placement) return ''; } + */ $defaults = array( 'messageClass' => 'NoticeMessage', // class for messages diff --git a/wire/core/Modules.php b/wire/core/Modules.php index 307afcaf..ce93ed00 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -742,8 +742,6 @@ class Modules extends WireArray { /** * Retrieve the installed module info as stored in the database * - * @return array Indexed by module class name => array of module info - * */ protected function loadModulesTable() { $database = $this->wire('database'); @@ -2648,8 +2646,11 @@ class Modules extends WireArray { // if $info[requires] or $info[installs] isn't already an array, make it one if(!is_array($info['requires'])) { $info['requires'] = str_replace(' ', '', $info['requires']); // remove whitespace - if(strpos($info['requires'], ',') !== false) $info['requires'] = explode(',', $info['requires']); - else $info['requires'] = array($info['requires']); + if(strpos($info['requires'], ',') !== false) { + $info['requires'] = explode(',', $info['requires']); + } else { + $info['requires'] = array($info['requires']); + } } // populate requiresVersions @@ -2669,8 +2670,11 @@ class Modules extends WireArray { // what does it install? if(!is_array($info['installs'])) { $info['installs'] = str_replace(' ', '', $info['installs']); // remove whitespace - if(strpos($info['installs'], ',') !== false) $info['installs'] = explode(',', $info['installs']); - else $info['installs'] = array($info['installs']); + if(strpos($info['installs'], ',') !== false) { + $info['installs'] = explode(',', $info['installs']); + } else { + $info['installs'] = array($info['installs']); + } } // misc diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 2db741a0..dc786642 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -45,7 +45,7 @@ class ProcessWire extends Wire { * Reversion revision number * */ - const versionRevision = 77; + const versionRevision = 78; /** * Version suffix string (when applicable) diff --git a/wire/core/admin.php b/wire/core/admin.php index 538a4cd9..e10d0ca0 100644 --- a/wire/core/admin.php +++ b/wire/core/admin.php @@ -107,7 +107,7 @@ if($page->process && $page->process != 'ProcessPageView') { $initFile = $wire->files->compile($initFile); } /** @noinspection PhpIncludeInspection */ - include($initFile); + include_once($initFile); } if($input->get('modal')) $session->addHookBefore('redirect', null, '_hookSessionRedirectModal'); $content = $controller->execute(); diff --git a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module index 14a7c14e..adc662a4 100644 --- a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module +++ b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module @@ -49,6 +49,9 @@ * @property string $subfieldIdentifier ... * @property string $groupIdentifier (1) * @property int $maxUsers [20] Maximum number of users selectable. If more than regular text input used rather than select. + * @property string $selectClass + * @property string $inputClass + * @property string $checkboxClass * * */ @@ -131,6 +134,13 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { */ protected $initTemplate = null; + /** + * Has the ready method been called? + * @var bool + * + */ + protected $isReady = false; + /** * Variable names that should be picked up through the session each time * @@ -202,7 +212,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { $this->setting('timeFormat', $this->_('H:i')); // time format $this->setting('timePlaceholder', $this->_('hh:mm')); // time format placeholder (what users see) $this->setting('maxUsers', 20); // text input rather than select used when useres qty is greater than this - + parent::__construct(); } @@ -247,6 +257,21 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { * */ public function ready() { + + if($this->isReady) return; + $this->isReady = true; + + // settings specified in $config->InputfieldSelector + $configDefaults = array( + 'selectClass' => '', + 'inputClass' => '', + 'checkboxClass' => '', + ); + $configSettings = $this->wire('config')->InputfieldSelector; + $configSettings = is_array($configSettings) ? array_merge($configDefaults, $configSettings) : $configDefaults; + foreach($configSettings as $key => $value) { + $this->setting($key, $value); + } $input = $this->wire('input'); $name = $input->get('name'); @@ -902,7 +927,8 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { $outSections['adjust'] = ""; $inputName = $this->attr('name') . "__" . $settings['name'] . "[]"; - $out = ""; if(!$this->showOptgroups) { ksort($outAll); @@ -1051,7 +1077,8 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { } $disabled = count($operators) ? "" : " disabled='disabled'"; - $out = ""; + $selectClass = trim("$this->selectClass select-operator"); + $out = ""; foreach($operators as $key => $label) { if(isset($this->operators[$label])) { @@ -1270,7 +1297,8 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { if(in_array($type, array('select', 'page', 'checkbox'))) { // render a "; + $selectClass = trim("$this->selectClass select-value input-value"); + $out .= ""; - $out .= ""; + $inputClass = trim("$this->inputClass input-value-autocomplete"); + $out .= ""; } else if($type == 'datetime' || $type == 'date') { // render date/datetime input @@ -1324,7 +1353,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { } else { // render other input that uses an whether text, number or selector $inputType = $type; - $inputClass = "input-value input-value-$type"; + $inputClass = trim("$this->inputClass input-value input-value-$type"); if($type == 'number' || $type == 'selector' || $fieldName == 'id' || $subfield == 'id') { // adding this class tells InputfieldSelector.js that selector strings are allowed for this input @@ -1338,7 +1367,8 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { // end the opval row by rendering a checkbox for the OR option $orLabel = $this->_('Check box to make this row OR rather than AND'); $orChecked = $orChecked ? ' checked' : ''; - $out .= ""; + $checkboxClass = trim("$this->checkboxClass input-or"); + $out .= ""; return $out; } @@ -1409,7 +1439,8 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { $inputName = $this->attr('name') . "__" . $field->name . "[]"; $outSub = ''; // subselector optgroup output - $out = ""; $out .= ""; // determine if there is a current value string and if it contains a selector string @@ -1705,6 +1736,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { * */ public function ___render() { + $this->ready(); // tell jQuery UI we want it to load the modal component which makes a.modal open modal windows $this->wire('modules')->get('JqueryUI')->use('modal'); diff --git a/wire/modules/Process/ProcessPageList/ProcessPageList.js b/wire/modules/Process/ProcessPageList/ProcessPageList.js index 1e8d5273..c1e02a0d 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageList.js +++ b/wire/modules/Process/ProcessPageList/ProcessPageList.js @@ -123,6 +123,9 @@ $(document).ready(function() { // milliseconds in fade time to reveal or hide hover actions hoverActionFade: 150, + // show only edit and view actions, and make everything else extra actions + useNarrowActions: $('body').hasClass('pw-narrow-width'), + // markup for the spinner used when ajax calls are made spinnerMarkup: "", @@ -622,7 +625,8 @@ $(document).ready(function() { function addClickEvents($ul) { $("a.PageListPage", $ul).click(clickChild); - $(".PageListActionMove a", $ul).click(clickMove); + $ul.on('click', '.PageListActionMove a', clickMove); + // $(".PageListActionMove a", $ul).click(clickMove); $(".PageListActionSelect a", $ul).click(clickSelect); $(".PageListTriggerOpen:not(.PageListID1) > a.PageListPage", $ul).click(); $(".PageListActionExtras > a:not(.clickExtras)", $ul).addClass('clickExtras').on('click', clickExtras); @@ -644,8 +648,8 @@ $(document).ready(function() { .attr('title', child.path) .html(child.label) .addClass('PageListPage label'); - - $li.addClass('PageListID' + child.id); + + $li.addClass(child.numChildren > 0 ? 'PageListHasChildren' : 'PageListNoChildren').addClass('PageListID' + child.id); if(child.status == 0) $li.addClass('PageListStatusOff disabled'); if(child.status & 2048) $li.addClass('PageListStatusUnpublished secondary'); if(child.status & 1024) $li.addClass('PageListStatusHidden secondary'); @@ -676,13 +680,26 @@ $(document).ready(function() { } var $lastAction = null; + var $extrasLink = null; // link that toggles extra actions + var extras = {}; // extra actions + $(links).each(function(n, action) { var actionName; - if(action.name == options.selectSelectLabel) actionName = 'Select'; - else if(action.name == options.selectUnselectLabel) actionName = 'Select'; - else actionName = action.cn; // cn = className - + if(action.name == options.selectSelectLabel) { + actionName = 'Select'; + } else if(action.name == options.selectUnselectLabel) { + actionName = 'Select'; + } else { + actionName = action.cn; // cn = className + if(options.useNarrowActions && (actionName != 'Edit' && actionName != 'View' && actionName != 'Extras')) { + // move non-edit/view actions to extras when in narrow mode + extras[actionName] = action; + return; + } + } + var $a = $("").html(action.name).attr('href', action.url); + if(!isModal) { if(action.cn == 'Edit') { $a.addClass('pw-modal pw-modal-large pw-modal-longclick'); @@ -691,13 +708,20 @@ $(document).ready(function() { $a.addClass('pw-modal pw-modal-large pw-modal-longclick'); } } + if(typeof action.extras != "undefined") { - $a.data('extras', action.extras); + for(var key in action.extras) { + extras[key] = action.extras[key]; + } + $extrasLink = $a; } var $action = $("
  • ").addClass('PageListAction' + actionName).append($a); if(actionName == 'Extras') $lastAction = $action; else $actions.append($action); - }); + }); + + if($extrasLink) $extrasLink.data('extras', extras); + if($lastAction) { $actions.append($lastAction); $lastAction.addClass('ui-priority-secondary'); diff --git a/wire/modules/Process/ProcessPageList/ProcessPageList.min.js b/wire/modules/Process/ProcessPageList/ProcessPageList.min.js index 02622aaf..d0668f62 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageList.min.js +++ b/wire/modules/Process/ProcessPageList/ProcessPageList.min.js @@ -1 +1 @@ -function ProcessPageListInit(){if(ProcessWire.config.ProcessPageList){$("#"+ProcessWire.config.ProcessPageList.containerID).ProcessPageList(ProcessWire.config.ProcessPageList)}}$(document).ready(function(){ProcessPageListInit()});(function(a){a.fn.ProcessPageList=function(c){var d={mode:"",limit:35,rootPageID:0,showRootPage:true,selectedPageID:0,adminPageID:2,trashPageID:7,langID:0,selectAllowUnselect:false,selectShowPageHeader:true,selectShowPath:true,selectStartLabel:"Change",selectCancelLabel:"Cancel",selectSelectLabel:"Select",selectUnselectLabel:"Unselect",moreLabel:"More",trashLabel:"Trash",moveInstructionLabel:"Click and drag to move",selectSelectHref:"#",selectUnselectHref:"#",ajaxURL:ProcessWire.config.urls.admin+"page/list/",ajaxMoveURL:ProcessWire.config.urls.admin+"page/sort/",paginationClass:"PageListPagination",paginationCurrentClass:"PageListPaginationCurrent",paginationLinkClass:"ui-state-default",paginationLinkCurrentClass:"ui-state-active",paginationHoverClass:"ui-state-hover",paginationDisabledClass:"ui-priority-secondary",openPagination:0,openPageIDs:[],openPageData:{},speed:200,useHoverActions:false,hoverActionDelay:250,hoverActionFade:150,spinnerMarkup:"",labelName:""};var b=[];var f=false;var e=a("body").hasClass("modal")||a("body").hasClass("pw-iframe");a.extend(d,c);return this.each(function(l){var v=a(this);var E;var u=a(d.spinnerMarkup);var G=0;var h=0;function y(){E=a("
    ");if(v.is(":input")){d.selectedPageID=v.val();if(!d.selectedPageID.length){d.selectedPageID=0}d.mode="select";v.before(E);C()}else{d.mode="actions";v.append(E);m(d.rootPageID>0?d.rootPageID:1,E,0,true)}a(document).on("pageListRefresh",function(I,H){F(H)});if(d.useHoverActions){E.addClass("PageListUseHoverActions");o()}}function o(){var J=null;var K=null;var I=null;function H(M){var N=M.find(".PageListActions");if(!N.is(":visible")||M.hasClass("PageListItemOpen")){M.addClass("PageListItemHover");N.css("display","inline").css("opacity",0).animate({opacity:1},d.hoverActionFade)}}function L(M){var N=M.find(".PageListActions");M.removeClass("PageListItemHover");if(N.is(":visible")){N.animate({opacity:0},d.hoverActionFade,function(){N.hide()})}}a(document).on("keydown",".PageListItem",function(N){N=N||window.event;if(N.keyCode==0||N.keyCode==32){var M=a(this).find(".PageListActions");if(M.is(":visible")){M.css("display","none")}else{M.css("display","inline-block")}return false}});a(document).on("mouseover",".PageListItem",function(O){if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return}if(!a(this).children("a:first").is(":hover")){return}I=a(this);if(I.hasClass("PageListItemHover")){return}var M=a(this);if(J){clearTimeout(J)}var N=d.hoverActionDelay;J=setTimeout(function(){if(I.attr("class")==M.attr("class")){if(!I.children("a:first").is(":hover")){return}var P=a(".PageListItemHover");H(I);P.each(function(){L(a(this))})}},N)}).on("mouseout",".PageListItem",function(O){if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return}var M=a(this);if(M.hasClass("PageListItemOpen")){return}if(!M.hasClass("PageListItemHover")){return}var N=d.hoverActionDelay*0.7;K=setTimeout(function(){if(M.is(":hover")){return}if(M.attr("class")==I.attr("class")){return}L(M)},N)})}function C(){var H=a("
      ").addClass("PageListActions PageListSelectActions actions");var J=a("

      ").addClass("PageListSelectName");if(d.selectShowPageHeader){J.append(u)}var K=a("").addClass("PageListSelectActionToggle").attr("href","#").text(d.selectStartLabel).click(function(){if(a(this).text()==d.selectStartLabel){m(d.rootPageID>0?d.rootPageID:1,E,0,true);a(this).text(d.selectCancelLabel)}else{E.children(".PageList").slideUp(d.speed,function(){a(this).remove()});a(this).text(d.selectStartLabel)}return false});H.append(a("
    • ").append(K));E.append(a("
      ").addClass("PageListSelectHeader").append(J).append(H));if(d.selectShowPageHeader){var I=d.ajaxURL+"?id="+d.selectedPageID+"&render=JSON&start=0&limit=0&lang="+d.langID+"&mode="+d.mode;if(d.labelName.length){I+="&labelName="+d.labelName}a.getJSON(I,function(N){var L="";if(d.selectShowPath){L=N.page.path;if(L.substring(-1)=="/"){L=L.substring(0,L.length-1)}L=L.substring(0,L.lastIndexOf("/")+1);L=''+L+" "}var M=d.selectedPageID>0?L+N.page.label:"";E.children(".PageListSelectHeader").find(".PageListSelectName").html(M)})}}function x(){f=false}function z(H,I,O,S){var Q=9;var J=Math.ceil(S/O);h=I>=O?Math.floor(I/O):0;if(h==0){G=0}else{if((h-Q+1)>G){G=h-Math.floor(Q/2)}else{if(G>0&&h==G){G=h-Math.ceil(Q/2)}}}if(G>J-Q){G=J-Q}if(G<0){G=0}var P=a("
        ").addClass(d.paginationClass).data("paginationInfo",{start:I,limit:O,total:S});var R=function(ab){var V=a(this).parents("ul."+d.paginationClass);var aa=V.data("paginationInfo");if(!aa){return false}var ac=parseInt(a(this).attr("href"))*aa.limit;if(ac===NaN){ac=0}var W=z(H,ac,aa.limit,aa.total);var Y=a(d.spinnerMarkup);var Z=a("
      •  
      • ").addClass(d.paginationDisabledClass).append(Y.hide());V.siblings(".PageList").remove();V.replaceWith(W);W.append(Z);Y.fadeIn("fast");var X=W.siblings().css("opacity",0.5);m(H,W.parent(),a(this).attr("href")*aa.limit,false,false,true,function(){Y.fadeOut("fast",function(){Z.remove()});W.parent(".PageList").prev(".PageListItem").data("start",ac);g()});return false};var N=null;var K=null;for(var U=G,L=0;U").html(U+1).attr("href",U).addClass(d.paginationLinkClass);var T=a("
      • ").addClass(d.paginationClass+L).append(M);if(U==h){T.addClass(d.paginationCurrentClass).find("a").removeClass(d.paginationLinkClass).addClass(d.paginationLinkCurrentClass)}P.append(T);if(!K){K=T.clone().removeClass(d.paginationCurrentClass+" "+d.paginationLinkCurrentClass);K.find("a").removeClass(d.paginationLinkCurrentClass).addClass(d.paginationLinkClass)}if(!N){N=K.clone().removeClass(d.paginationLinkClass).addClass(d.paginationDisabledClass).html("…")}if(L>=Q&&U0){$firstItem=K.clone();$firstItem.find("a").text("1").attr("href","0").click(R);P.prepend(N.clone()).prepend($firstItem)}if(h+1").attr("href",h+1);P.append($nextBtn)}if(h>0){$prevBtn=K.clone();$prevBtn.find("a").attr("href",h-1).html("");P.prepend($prevBtn)}P.find("a").click(R).hover(function(){a(this).addClass(d.paginationHoverClass)},function(){a(this).removeClass(d.paginationHoverClass)});return P}function m(I,L,J,N,Q,K,P){if(Q==undefined){Q=true}if(K==undefined){K=false}var M=function(V){if(V&&V.error){ProcessWire.alert(V.message);u.hide();f=false;return}var R=k(a(V.children));var U=V.start+V.limit;if(V.page.numChildren>U){var T=a("").attr("href",U).data("pageId",I).text(d.moreLabel).click(B);R.append(a("
          ").addClass("PageListActions actions").append(a("
        • ").addClass("PageListActionMore").append(T)))}if(Q&&(V.page.numChildren>U||V.start>0)){R.prepend(z(I,V.start,V.limit,V.page.numChildren))}R.hide();if(N){var W;W=k(a(V.page));if(d.showRootPage){W.children(".PageListItem").addClass("PageListItemOpen")}else{W.children(".PageListItem").hide().parent(".PageList").addClass("PageListRootHidden")}W.append(R);L.append(W)}else{if(L.is(".PageList")){var S=R.children(".PageListItem, .PageListActions");if(K){L.children(".PageListItem, .PageListActions").replaceWith(S)}else{L.append(S)}}else{L.after(R)}}if(u.parent().is(".PageListRoot")){u.hide()}else{u.fadeOut("fast")}if(K){R.show();x();if(P!=undefined){P()}}else{R.slideDown(d.speed,function(){x();if(P!=undefined){P()}})}R.prev(".PageListItem").data("start",V.start);L.removeClass("PageListForceReload")};if(!K){L.append(u.fadeIn("fast"))}var O=I+"-"+J;if(typeof d.openPageData[O]!="undefined"&&!L.hasClass("PageListID7")&&!L.hasClass("PageListForceReload")){M(d.openPageData[O]);return}var H=d.ajaxURL+"?id="+I+"&render=JSON&start="+J+"&lang="+d.langID+"&open="+d.openPageIDs[0]+"&mode="+d.mode;if(d.labelName.length){H+="&labelName="+d.labelName}a.getJSON(H).done(function(S,T,R){M(S)}).fail(function(R,T,S){M({error:1,message:!R.status?d.ajaxNetworkError:d.ajaxUnknownError})})}function k(H){var J=a("
          ").addClass("PageList");var I=J;H.each(function(L,K){I.append(j(K))});s(I);return J}function s(H){a("a.PageListPage",H).click(t);a(".PageListActionMove a",H).click(i);a(".PageListActionSelect a",H).click(A);a(".PageListTriggerOpen:not(.PageListID1) > a.PageListPage",H).click();a(".PageListActionExtras > a:not(.clickExtras)",H).addClass("clickExtras").on("click",p)}function j(N){var M=a("
          ").data("pageId",N.id).addClass("PageListItem").addClass("PageListTemplate_"+N.template);var L=a("").attr("href","#").attr("title",N.path).html(N.label).addClass("PageListPage label");M.addClass("PageListID"+N.id);if(N.status==0){M.addClass("PageListStatusOff disabled")}if(N.status&2048){M.addClass("PageListStatusUnpublished secondary")}if(N.status&1024){M.addClass("PageListStatusHidden secondary")}if(N.status&512){M.addClass("PageListStatusTemp secondary")}if(N.status&16){M.addClass("PageListStatusSystem")}if(N.status&8){M.addClass("PageListStatusSystem")}if(N.status&4){M.addClass("PageListStatusLocked")}if(N.addClass&&N.addClass.length){M.addClass(N.addClass)}if(N.type&&N.type.length>0){if(N.type=="System"){M.addClass("PageListStatusSystem")}}a(d.openPageIDs).each(function(P,O){O=parseInt(O);if(N.id==O){M.addClass("PageListTriggerOpen")}});M.append(L);var J=a(""+(N.numChildren?N.numChildren:"")+"").addClass("PageListNumChildren detail");M.append(J);if(N.note&&N.note.length){M.append(a(""+N.note+"").addClass("PageListNote detail"))}var K=a("
            ").addClass("PageListActions actions");var I=d.rootPageID==N.id?[]:[{name:d.selectSelectLabel,url:d.selectSelectHref}];if(d.mode=="actions"){I=N.actions}else{if(d.selectAllowUnselect){if(N.id==v.val()){I=[{name:d.selectUnselectLabel,url:d.selectUnselectHref}]}}}var H=null;a(I).each(function(S,Q){var O;if(Q.name==d.selectSelectLabel){O="Select"}else{if(Q.name==d.selectUnselectLabel){O="Select"}else{O=Q.cn}}var P=a("").html(Q.name).attr("href",Q.url);if(!e){if(Q.cn=="Edit"){P.addClass("pw-modal pw-modal-large pw-modal-longclick");P.attr("data-buttons","#ProcessPageEdit > .Inputfields > .InputfieldSubmit .ui-button")}else{if(Q.cn=="View"){P.addClass("pw-modal pw-modal-large pw-modal-longclick")}}}if(typeof Q.extras!="undefined"){P.data("extras",Q.extras)}var R=a("
          • ").addClass("PageListAction"+O).append(P);if(O=="Extras"){H=R}else{K.append(R)}});if(H){K.append(H);H.addClass("ui-priority-secondary")}M.append(K);return M}function p(O){var I=a(this);var K=I.data("extras");if(typeof K=="undefined"){return false}var R=I.closest(".PageListItem");var S=I.closest(".PageListActions");var M=null;var P=I.children("i.fa");var Q=S.find("li.PageListActionExtra");P.toggleClass("fa-flip-horizontal");if(Q.length){Q.fadeOut(100,function(){Q.remove()});return false}for(var J in K){var H=K[J];var N=a("").addClass("PageListActionExtra PageListAction"+H.cn).attr("href",H.url).html(H.name);if(typeof H.ajax!="undefined"&&H.ajax==true){N.click(function(){R.find(".PageListActions").hide();var Z=a(d.spinnerMarkup);var W=a(this).attr("href");var V=W.match(/[\?&]action=([-_a-zA-Z0-9]+)/)[1];var U=parseInt(W.match(/[\?&]id=([0-9]+)/)[1]);var Y=a("#PageListContainer").attr("data-token-name");var X=a("#PageListContainer").attr("data-token-value");var T={action:V,id:U};T[Y]=X;R.append(Z);a.post(W+"&render=json",T,function(aa){if(aa.success){R.fadeOut("fast",function(){var ag=false;var ah=aa.remove;var af=aa.refreshChildren;var ad=false;if(typeof aa.child!="undefined"){ad=j(aa.child)}else{if(typeof aa.newChild!="undefined"){ad=j(aa.newChild);ag=true}}if(ad){var ab=a("").addClass("notes").html(aa.message);ab.prepend("  ");ad.append(ab);s(ad)}if(ag){Z.fadeOut("normal",function(){Z.remove()});ad.hide();R.after(ad);ad.slideDown()}else{if(ad){if(R.hasClass("PageListItemOpen")){ad.addClass("PageListItemOpen")}R.replaceWith(ad)}}R.fadeIn("fast",function(){setTimeout(function(){ab.fadeOut("normal",function(){if(ah){var ai=ad.closest(".PageList").prev(".PageListItem").children(".PageListNumChildren");if(ai.length){var aj=parseInt(ai.text());if(aj>0){ai.text(aj-1)}}ad.next(".PageList").fadeOut("fast");ad.fadeOut("fast",function(){ad.remove()})}else{ab.remove()}})},1000)});if(af){var ac=a(".PageListID"+af);if(ac.length){ac.addClass("PageListForceReload");var ae=ac.children("a.PageListPage");if(ac.hasClass("PageListItemOpen")){ae.click();setTimeout(function(){ae.click()},250)}else{ae.click()}}}})}else{Z.remove();ProcessWire.alert(aa.message)}});return false})}else{}var L=a("
          • ").addClass("PageListActionExtra PageListAction"+H.cn).append(N);N.hide();if(H.cn=="Trash"){R.addClass("trashable");M=L}else{S.append(L)}}if(M){S.append(M)}S.find(".PageListActionExtra a").fadeIn(50,function(){a(this).css("display","inline-block")});return false}function t(K){var O=a(this);var N=O.parent(".PageListItem");var M=N.data("pageId");if(f&&!N.hasClass("PageListTriggerOpen")){return false}if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return false}if(N.hasClass("PageListItemOpen")){var H=true;if(N.hasClass("PageListID1")&&!N.hasClass("PageListForceReload")&&d.mode!="select"){var I=a(this).closest(".PageListRoot").find(".PageListItemOpen:not(.PageListID1)");if(I.length){E.find(".PageListItemOpen:not(.PageListID1)").each(function(){a(this).children("a.PageListPage").click()});H=false}}if(H){N.removeClass("PageListItemOpen").next(".PageList").slideUp(d.speed,function(){a(this).remove()})}}else{N.addClass("PageListItemOpen");var J=parseInt(N.children(".PageListNumChildren").text());if(J>0||N.hasClass("PageListForceReload")){f=true;var L=D(M);m(M,N,L,false)}}if(d.mode!="select"){setTimeout(function(){g()},250)}return false}function D(L){var K=0;for(n=0;n1&&a(this).next().find(".PageList:visible").size()==0){return}var O=a("
            ").addClass("PageListPlaceholder").addClass("PageList");O.append(a("
            ").addClass("PageListItem PageListPlaceholderItem").html(" "));a(this).after(O)});var L={stop:q,helper:"PageListItemHelper",items:".PageListItem:not(.PageListItemOpen)",placeholder:"PageListSortPlaceholder",start:function(P,O){a(".PageListSortPlaceholder").css("width",O.item.children(".PageListPage").outerWidth()+"px")}};var I=E.children(".PageList").children(".PageList");var H=a("
            "+d.selectCancelLabel+"").click(function(){return r(M)});var K=M.children("ul.PageListActions");var J=a(" "+d.moveInstructionLabel+"");J.append(H);K.before(J);M.addClass("PageListSortItem");M.parent(".PageList").attr("id","PageListMoveFrom");E.addClass("PageListSorting");I.addClass("PageListSortingList").sortable(L);return false}function r(I){var H=E.find(".PageListSortingList");H.sortable("destroy").removeClass("PageListSortingList");I.removeClass("PageListSortItem").parent(".PageList").removeAttr("id");I.find(".PageListMoveNote").remove();E.find(".PageListPlaceholder").remove();E.removeClass("PageListSorting");return false}function w(K){var H=E.find(".PageListID"+d.trashPageID);if(!H.hasClass("PageListItemOpen")){E.removeClass("PageListSorting");H.children("a").click();E.addClass("PageListSorting")}var I=H.next(".PageList");if(I.length==0){I=a("
            ");H.after(I)}I.prepend(K);var J={item:K};q(null,J)}function q(N,S){var P=S.item;var K=P.children(".PageListPage");var I=parseInt(P.data("pageId"));var M=P.parent(".PageList");var Q=a("#PageListMoveFrom");var R=M.prev().is(".PageListItem")?M.prev():M.prev().prev();var O=parseInt(R.data("pageId"));var J=P.prev(".PageListItem");if(J.is(".PageListItemOpen")){return false}if(M.is(".PageListPlaceholder")){M.removeClass("PageListPlaceholder").children(".PageListPlaceholderItem").remove()}E.addClass("PageListSortSaving");r(P);P.append(u.fadeIn("fast"));var L="";M.children(".PageListItem").each(function(){L+=a(this).data("pageId")+","});var H={id:I,parent_id:O,sort:L};H[a("#PageListContainer").attr("data-token-name")]=a("#PageListContainer").attr("data-token-value");var T="unknown";a.post(d.ajaxMoveURL,H,function(W){u.fadeOut("fast");K.fadeOut("fast",function(){a(this).fadeIn("fast");P.removeClass("PageListSortItem");E.removeClass("PageListSorting")});if(W&&W.error){ProcessWire.alert(W.message)}if(!M.is("#PageListMoveFrom")){var V=Q.prev(".PageListItem");var U=V.children(".PageListNumChildren");var Y=U.text().length>0?parseInt(U.text())-1:0;if(Y==0){Y="";Q.remove()}U.text(Y);var X=M.prev(".PageListItem");U=X.children(".PageListNumChildren");Y=U.text().length>0?parseInt(U.text())+1:1;U.text(Y)}Q.attr("id","");E.removeClass("PageListSortSaving")},"json");P.trigger("pageMoved");return true}function A(){var N=a(this);var M=N.parent("li").parent("ul.PageListActions").parent(".PageListItem");var L=M.data("pageId");var J=M.children(".PageListPage");var K=J.text();var I=J.attr("title");var H=E.children(".PageListSelectHeader");if(N.text()==d.selectUnselectLabel){L=0;K=""}if(L!=v.val()){v.val(L).change()}if(d.selectShowPageHeader){H.children(".PageListSelectName").text(K)}v.trigger("pageSelected",{id:L,url:I,title:K,a:J});H.find(".PageListSelectActionToggle").click();if(d.selectSelectHref=="#"){return false}return true}y()})}})(jQuery); \ No newline at end of file +function ProcessPageListInit(){if(ProcessWire.config.ProcessPageList){$("#"+ProcessWire.config.ProcessPageList.containerID).ProcessPageList(ProcessWire.config.ProcessPageList)}}$(document).ready(function(){ProcessPageListInit()});(function(a){a.fn.ProcessPageList=function(c){var d={mode:"",limit:35,rootPageID:0,showRootPage:true,selectedPageID:0,adminPageID:2,trashPageID:7,langID:0,selectAllowUnselect:false,selectShowPageHeader:true,selectShowPath:true,selectStartLabel:"Change",selectCancelLabel:"Cancel",selectSelectLabel:"Select",selectUnselectLabel:"Unselect",moreLabel:"More",trashLabel:"Trash",moveInstructionLabel:"Click and drag to move",selectSelectHref:"#",selectUnselectHref:"#",ajaxURL:ProcessWire.config.urls.admin+"page/list/",ajaxMoveURL:ProcessWire.config.urls.admin+"page/sort/",paginationClass:"PageListPagination",paginationCurrentClass:"PageListPaginationCurrent",paginationLinkClass:"ui-state-default",paginationLinkCurrentClass:"ui-state-active",paginationHoverClass:"ui-state-hover",paginationDisabledClass:"ui-priority-secondary",openPagination:0,openPageIDs:[],openPageData:{},speed:200,useHoverActions:false,hoverActionDelay:250,hoverActionFade:150,useNarrowActions:a("body").hasClass("pw-narrow-width"),spinnerMarkup:"",labelName:""};var b=[];var f=false;var e=a("body").hasClass("modal")||a("body").hasClass("pw-iframe");a.extend(d,c);return this.each(function(l){var v=a(this);var E;var u=a(d.spinnerMarkup);var G=0;var h=0;function y(){E=a("
            ");if(v.is(":input")){d.selectedPageID=v.val();if(!d.selectedPageID.length){d.selectedPageID=0}d.mode="select";v.before(E);C()}else{d.mode="actions";v.append(E);m(d.rootPageID>0?d.rootPageID:1,E,0,true)}a(document).on("pageListRefresh",function(I,H){F(H)});if(d.useHoverActions){E.addClass("PageListUseHoverActions");o()}}function o(){var J=null;var K=null;var I=null;function H(M){var N=M.find(".PageListActions");if(!N.is(":visible")||M.hasClass("PageListItemOpen")){M.addClass("PageListItemHover");N.css("display","inline").css("opacity",0).animate({opacity:1},d.hoverActionFade)}}function L(M){var N=M.find(".PageListActions");M.removeClass("PageListItemHover");if(N.is(":visible")){N.animate({opacity:0},d.hoverActionFade,function(){N.hide()})}}a(document).on("keydown",".PageListItem",function(N){N=N||window.event;if(N.keyCode==0||N.keyCode==32){var M=a(this).find(".PageListActions");if(M.is(":visible")){M.css("display","none")}else{M.css("display","inline-block")}return false}});a(document).on("mouseover",".PageListItem",function(O){if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return}if(!a(this).children("a:first").is(":hover")){return}I=a(this);if(I.hasClass("PageListItemHover")){return}var M=a(this);if(J){clearTimeout(J)}var N=d.hoverActionDelay;J=setTimeout(function(){if(I.attr("class")==M.attr("class")){if(!I.children("a:first").is(":hover")){return}var P=a(".PageListItemHover");H(I);P.each(function(){L(a(this))})}},N)}).on("mouseout",".PageListItem",function(O){if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return}var M=a(this);if(M.hasClass("PageListItemOpen")){return}if(!M.hasClass("PageListItemHover")){return}var N=d.hoverActionDelay*0.7;K=setTimeout(function(){if(M.is(":hover")){return}if(M.attr("class")==I.attr("class")){return}L(M)},N)})}function C(){var H=a("
              ").addClass("PageListActions PageListSelectActions actions");var J=a("

              ").addClass("PageListSelectName");if(d.selectShowPageHeader){J.append(u)}var K=a("").addClass("PageListSelectActionToggle").attr("href","#").text(d.selectStartLabel).click(function(){if(a(this).text()==d.selectStartLabel){m(d.rootPageID>0?d.rootPageID:1,E,0,true);a(this).text(d.selectCancelLabel)}else{E.children(".PageList").slideUp(d.speed,function(){a(this).remove()});a(this).text(d.selectStartLabel)}return false});H.append(a("
            • ").append(K));E.append(a("
              ").addClass("PageListSelectHeader").append(J).append(H));if(d.selectShowPageHeader){var I=d.ajaxURL+"?id="+d.selectedPageID+"&render=JSON&start=0&limit=0&lang="+d.langID+"&mode="+d.mode;if(d.labelName.length){I+="&labelName="+d.labelName}a.getJSON(I,function(N){var L="";if(d.selectShowPath){L=N.page.path;if(L.substring(-1)=="/"){L=L.substring(0,L.length-1)}L=L.substring(0,L.lastIndexOf("/")+1);L=''+L+" "}var M=d.selectedPageID>0?L+N.page.label:"";E.children(".PageListSelectHeader").find(".PageListSelectName").html(M)})}}function x(){f=false}function z(H,I,O,S){var Q=9;var J=Math.ceil(S/O);h=I>=O?Math.floor(I/O):0;if(h==0){G=0}else{if((h-Q+1)>G){G=h-Math.floor(Q/2)}else{if(G>0&&h==G){G=h-Math.ceil(Q/2)}}}if(G>J-Q){G=J-Q}if(G<0){G=0}var P=a("
                ").addClass(d.paginationClass).data("paginationInfo",{start:I,limit:O,total:S});var R=function(ab){var V=a(this).parents("ul."+d.paginationClass);var aa=V.data("paginationInfo");if(!aa){return false}var ac=parseInt(a(this).attr("href"))*aa.limit;if(ac===NaN){ac=0}var W=z(H,ac,aa.limit,aa.total);var Y=a(d.spinnerMarkup);var Z=a("
              •  
              • ").addClass(d.paginationDisabledClass).append(Y.hide());V.siblings(".PageList").remove();V.replaceWith(W);W.append(Z);Y.fadeIn("fast");var X=W.siblings().css("opacity",0.5);m(H,W.parent(),a(this).attr("href")*aa.limit,false,false,true,function(){Y.fadeOut("fast",function(){Z.remove()});W.parent(".PageList").prev(".PageListItem").data("start",ac);g()});return false};var N=null;var K=null;for(var U=G,L=0;U").html(U+1).attr("href",U).addClass(d.paginationLinkClass);var T=a("
              • ").addClass(d.paginationClass+L).append(M);if(U==h){T.addClass(d.paginationCurrentClass).find("a").removeClass(d.paginationLinkClass).addClass(d.paginationLinkCurrentClass)}P.append(T);if(!K){K=T.clone().removeClass(d.paginationCurrentClass+" "+d.paginationLinkCurrentClass);K.find("a").removeClass(d.paginationLinkCurrentClass).addClass(d.paginationLinkClass)}if(!N){N=K.clone().removeClass(d.paginationLinkClass).addClass(d.paginationDisabledClass).html("…")}if(L>=Q&&U0){$firstItem=K.clone();$firstItem.find("a").text("1").attr("href","0").click(R);P.prepend(N.clone()).prepend($firstItem)}if(h+1").attr("href",h+1);P.append($nextBtn)}if(h>0){$prevBtn=K.clone();$prevBtn.find("a").attr("href",h-1).html("");P.prepend($prevBtn)}P.find("a").click(R).hover(function(){a(this).addClass(d.paginationHoverClass)},function(){a(this).removeClass(d.paginationHoverClass)});return P}function m(I,L,J,N,Q,K,P){if(Q==undefined){Q=true}if(K==undefined){K=false}var M=function(V){if(V&&V.error){ProcessWire.alert(V.message);u.hide();f=false;return}var R=k(a(V.children));var U=V.start+V.limit;if(V.page.numChildren>U){var T=a("").attr("href",U).data("pageId",I).text(d.moreLabel).click(B);R.append(a("
                  ").addClass("PageListActions actions").append(a("
                • ").addClass("PageListActionMore").append(T)))}if(Q&&(V.page.numChildren>U||V.start>0)){R.prepend(z(I,V.start,V.limit,V.page.numChildren))}R.hide();if(N){var W;W=k(a(V.page));if(d.showRootPage){W.children(".PageListItem").addClass("PageListItemOpen")}else{W.children(".PageListItem").hide().parent(".PageList").addClass("PageListRootHidden")}W.append(R);L.append(W)}else{if(L.is(".PageList")){var S=R.children(".PageListItem, .PageListActions");if(K){L.children(".PageListItem, .PageListActions").replaceWith(S)}else{L.append(S)}}else{L.after(R)}}if(u.parent().is(".PageListRoot")){u.hide()}else{u.fadeOut("fast")}if(K){R.show();x();if(P!=undefined){P()}}else{R.slideDown(d.speed,function(){x();if(P!=undefined){P()}})}R.prev(".PageListItem").data("start",V.start);L.removeClass("PageListForceReload")};if(!K){L.append(u.fadeIn("fast"))}var O=I+"-"+J;if(typeof d.openPageData[O]!="undefined"&&!L.hasClass("PageListID7")&&!L.hasClass("PageListForceReload")){M(d.openPageData[O]);return}var H=d.ajaxURL+"?id="+I+"&render=JSON&start="+J+"&lang="+d.langID+"&open="+d.openPageIDs[0]+"&mode="+d.mode;if(d.labelName.length){H+="&labelName="+d.labelName}a.getJSON(H).done(function(S,T,R){M(S)}).fail(function(R,T,S){M({error:1,message:!R.status?d.ajaxNetworkError:d.ajaxUnknownError})})}function k(H){var J=a("
                  ").addClass("PageList");var I=J;H.each(function(L,K){I.append(j(K))});s(I);return J}function s(H){a("a.PageListPage",H).click(t);H.on("click",".PageListActionMove a",i);a(".PageListActionSelect a",H).click(A);a(".PageListTriggerOpen:not(.PageListID1) > a.PageListPage",H).click();a(".PageListActionExtras > a:not(.clickExtras)",H).addClass("clickExtras").on("click",p)}function j(H){var M=a("
                  ").data("pageId",H.id).addClass("PageListItem").addClass("PageListTemplate_"+H.template);var I=a("").attr("href","#").attr("title",H.path).html(H.label).addClass("PageListPage label");M.addClass(H.numChildren>0?"PageListHasChildren":"PageListNoChildren").addClass("PageListID"+H.id);if(H.status==0){M.addClass("PageListStatusOff disabled")}if(H.status&2048){M.addClass("PageListStatusUnpublished secondary")}if(H.status&1024){M.addClass("PageListStatusHidden secondary")}if(H.status&512){M.addClass("PageListStatusTemp secondary")}if(H.status&16){M.addClass("PageListStatusSystem")}if(H.status&8){M.addClass("PageListStatusSystem")}if(H.status&4){M.addClass("PageListStatusLocked")}if(H.addClass&&H.addClass.length){M.addClass(H.addClass)}if(H.type&&H.type.length>0){if(H.type=="System"){M.addClass("PageListStatusSystem")}}a(d.openPageIDs).each(function(R,Q){Q=parseInt(Q);if(H.id==Q){M.addClass("PageListTriggerOpen")}});M.append(I);var J=a(""+(H.numChildren?H.numChildren:"")+"").addClass("PageListNumChildren detail");M.append(J);if(H.note&&H.note.length){M.append(a(""+H.note+"").addClass("PageListNote detail"))}var N=a("
                    ").addClass("PageListActions actions");var P=d.rootPageID==H.id?[]:[{name:d.selectSelectLabel,url:d.selectSelectHref}];if(d.mode=="actions"){P=H.actions}else{if(d.selectAllowUnselect){if(H.id==v.val()){P=[{name:d.selectUnselectLabel,url:d.selectUnselectHref}]}}}var L=null;var O=null;var K={};a(P).each(function(V,T){var Q;if(T.name==d.selectSelectLabel){Q="Select"}else{if(T.name==d.selectUnselectLabel){Q="Select"}else{Q=T.cn;if(d.useNarrowActions&&(Q!="Edit"&&Q!="View"&&Q!="Extras")){K[Q]=T;return}}}var S=a("").html(T.name).attr("href",T.url);if(!e){if(T.cn=="Edit"){S.addClass("pw-modal pw-modal-large pw-modal-longclick");S.attr("data-buttons","#ProcessPageEdit > .Inputfields > .InputfieldSubmit .ui-button")}else{if(T.cn=="View"){S.addClass("pw-modal pw-modal-large pw-modal-longclick")}}}if(typeof T.extras!="undefined"){for(var R in T.extras){K[R]=T.extras[R]}O=S}var U=a("
                  • ").addClass("PageListAction"+Q).append(S);if(Q=="Extras"){L=U}else{N.append(U)}});if(O){O.data("extras",K)}if(L){N.append(L);L.addClass("ui-priority-secondary")}M.append(N);return M}function p(O){var I=a(this);var K=I.data("extras");if(typeof K=="undefined"){return false}var R=I.closest(".PageListItem");var S=I.closest(".PageListActions");var M=null;var P=I.children("i.fa");var Q=S.find("li.PageListActionExtra");P.toggleClass("fa-flip-horizontal");if(Q.length){Q.fadeOut(100,function(){Q.remove()});return false}for(var J in K){var H=K[J];var N=a("").addClass("PageListActionExtra PageListAction"+H.cn).attr("href",H.url).html(H.name);if(typeof H.ajax!="undefined"&&H.ajax==true){N.click(function(){R.find(".PageListActions").hide();var Z=a(d.spinnerMarkup);var W=a(this).attr("href");var V=W.match(/[\?&]action=([-_a-zA-Z0-9]+)/)[1];var U=parseInt(W.match(/[\?&]id=([0-9]+)/)[1]);var Y=a("#PageListContainer").attr("data-token-name");var X=a("#PageListContainer").attr("data-token-value");var T={action:V,id:U};T[Y]=X;R.append(Z);a.post(W+"&render=json",T,function(aa){if(aa.success){R.fadeOut("fast",function(){var ag=false;var ah=aa.remove;var af=aa.refreshChildren;var ad=false;if(typeof aa.child!="undefined"){ad=j(aa.child)}else{if(typeof aa.newChild!="undefined"){ad=j(aa.newChild);ag=true}}if(ad){var ab=a("").addClass("notes").html(aa.message);ab.prepend("  ");ad.append(ab);s(ad)}if(ag){Z.fadeOut("normal",function(){Z.remove()});ad.hide();R.after(ad);ad.slideDown()}else{if(ad){if(R.hasClass("PageListItemOpen")){ad.addClass("PageListItemOpen")}R.replaceWith(ad)}}R.fadeIn("fast",function(){setTimeout(function(){ab.fadeOut("normal",function(){if(ah){var ai=ad.closest(".PageList").prev(".PageListItem").children(".PageListNumChildren");if(ai.length){var aj=parseInt(ai.text());if(aj>0){ai.text(aj-1)}}ad.next(".PageList").fadeOut("fast");ad.fadeOut("fast",function(){ad.remove()})}else{ab.remove()}})},1000)});if(af){var ac=a(".PageListID"+af);if(ac.length){ac.addClass("PageListForceReload");var ae=ac.children("a.PageListPage");if(ac.hasClass("PageListItemOpen")){ae.click();setTimeout(function(){ae.click()},250)}else{ae.click()}}}})}else{Z.remove();ProcessWire.alert(aa.message)}});return false})}else{}var L=a("
                  • ").addClass("PageListActionExtra PageListAction"+H.cn).append(N);N.hide();if(H.cn=="Trash"){R.addClass("trashable");M=L}else{S.append(L)}}if(M){S.append(M)}S.find(".PageListActionExtra a").fadeIn(50,function(){a(this).css("display","inline-block")});return false}function t(K){var O=a(this);var N=O.parent(".PageListItem");var M=N.data("pageId");if(f&&!N.hasClass("PageListTriggerOpen")){return false}if(E.is(".PageListSorting")||E.is(".PageListSortSaving")){return false}if(N.hasClass("PageListItemOpen")){var H=true;if(N.hasClass("PageListID1")&&!N.hasClass("PageListForceReload")&&d.mode!="select"){var I=a(this).closest(".PageListRoot").find(".PageListItemOpen:not(.PageListID1)");if(I.length){E.find(".PageListItemOpen:not(.PageListID1)").each(function(){a(this).children("a.PageListPage").click()});H=false}}if(H){N.removeClass("PageListItemOpen").next(".PageList").slideUp(d.speed,function(){a(this).remove()})}}else{N.addClass("PageListItemOpen");var J=parseInt(N.children(".PageListNumChildren").text());if(J>0||N.hasClass("PageListForceReload")){f=true;var L=D(M);m(M,N,L,false)}}if(d.mode!="select"){setTimeout(function(){g()},250)}return false}function D(L){var K=0;for(n=0;n1&&a(this).next().find(".PageList:visible").size()==0){return}var O=a("
                    ").addClass("PageListPlaceholder").addClass("PageList");O.append(a("
                    ").addClass("PageListItem PageListPlaceholderItem").html(" "));a(this).after(O)});var L={stop:q,helper:"PageListItemHelper",items:".PageListItem:not(.PageListItemOpen)",placeholder:"PageListSortPlaceholder",start:function(P,O){a(".PageListSortPlaceholder").css("width",O.item.children(".PageListPage").outerWidth()+"px")}};var I=E.children(".PageList").children(".PageList");var H=a("
                    "+d.selectCancelLabel+"").click(function(){return r(M)});var K=M.children("ul.PageListActions");var J=a(" "+d.moveInstructionLabel+"");J.append(H);K.before(J);M.addClass("PageListSortItem");M.parent(".PageList").attr("id","PageListMoveFrom");E.addClass("PageListSorting");I.addClass("PageListSortingList").sortable(L);return false}function r(I){var H=E.find(".PageListSortingList");H.sortable("destroy").removeClass("PageListSortingList");I.removeClass("PageListSortItem").parent(".PageList").removeAttr("id");I.find(".PageListMoveNote").remove();E.find(".PageListPlaceholder").remove();E.removeClass("PageListSorting");return false}function w(K){var H=E.find(".PageListID"+d.trashPageID);if(!H.hasClass("PageListItemOpen")){E.removeClass("PageListSorting");H.children("a").click();E.addClass("PageListSorting")}var I=H.next(".PageList");if(I.length==0){I=a("
                    ");H.after(I)}I.prepend(K);var J={item:K};q(null,J)}function q(N,S){var P=S.item;var K=P.children(".PageListPage");var I=parseInt(P.data("pageId"));var M=P.parent(".PageList");var Q=a("#PageListMoveFrom");var R=M.prev().is(".PageListItem")?M.prev():M.prev().prev();var O=parseInt(R.data("pageId"));var J=P.prev(".PageListItem");if(J.is(".PageListItemOpen")){return false}if(M.is(".PageListPlaceholder")){M.removeClass("PageListPlaceholder").children(".PageListPlaceholderItem").remove()}E.addClass("PageListSortSaving");r(P);P.append(u.fadeIn("fast"));var L="";M.children(".PageListItem").each(function(){L+=a(this).data("pageId")+","});var H={id:I,parent_id:O,sort:L};H[a("#PageListContainer").attr("data-token-name")]=a("#PageListContainer").attr("data-token-value");var T="unknown";a.post(d.ajaxMoveURL,H,function(W){u.fadeOut("fast");K.fadeOut("fast",function(){a(this).fadeIn("fast");P.removeClass("PageListSortItem");E.removeClass("PageListSorting")});if(W&&W.error){ProcessWire.alert(W.message)}if(!M.is("#PageListMoveFrom")){var V=Q.prev(".PageListItem");var U=V.children(".PageListNumChildren");var Y=U.text().length>0?parseInt(U.text())-1:0;if(Y==0){Y="";Q.remove()}U.text(Y);var X=M.prev(".PageListItem");U=X.children(".PageListNumChildren");Y=U.text().length>0?parseInt(U.text())+1:1;U.text(Y)}Q.attr("id","");E.removeClass("PageListSortSaving")},"json");P.trigger("pageMoved");return true}function A(){var N=a(this);var M=N.parent("li").parent("ul.PageListActions").parent(".PageListItem");var L=M.data("pageId");var J=M.children(".PageListPage");var K=J.text();var I=J.attr("title");var H=E.children(".PageListSelectHeader");if(N.text()==d.selectUnselectLabel){L=0;K=""}if(L!=v.val()){v.val(L).change()}if(d.selectShowPageHeader){H.children(".PageListSelectName").text(K)}v.trigger("pageSelected",{id:L,url:I,title:K,a:J});H.find(".PageListSelectActionToggle").click();if(d.selectSelectHref=="#"){return false}return true}y()})}})(jQuery); \ No newline at end of file diff --git a/wire/modules/Process/ProcessPageList/ProcessPageListActions.php b/wire/modules/Process/ProcessPageList/ProcessPageListActions.php index 687612f9..1d974a25 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageListActions.php +++ b/wire/modules/Process/ProcessPageList/ProcessPageListActions.php @@ -18,10 +18,15 @@ class ProcessPageListActions extends Wire { 'unlock' => 'Unlock', 'trash' => 'Trash', 'restore' => 'Restore', + 'extras' => "", ); public function __construct() { $this->superuser = $this->wire('user')->isSuperuser(); + $settings = $this->wire('config')->ProcessPageList; + if(is_array($settings) && isset($settings['extrasLabel'])) { + $this->actionLabels['extras'] = $settings['extrasLabel']; + } } public function setActionLabels(array $actionLabels) { @@ -81,7 +86,7 @@ class ProcessPageListActions extends Wire { if(count($extras)) { $actions['extras'] = array( 'cn' => 'Extras', - 'name' => "", + 'name' => $this->actionLabels['extras'], 'url' => '#', 'extras' => $extras, ); diff --git a/wire/modules/System/SystemNotifications/Notifications.css b/wire/modules/System/SystemNotifications/Notifications.css index 5edb78e5..a655134d 100644 --- a/wire/modules/System/SystemNotifications/Notifications.css +++ b/wire/modules/System/SystemNotifications/Notifications.css @@ -5,6 +5,12 @@ background-color: #fff; } +.NotificationList { + margin: 0; + padding: 0; + list-style: none; +} + .NotificationList li { opacity: 0.95; } @@ -18,10 +24,11 @@ display: block; border-right: none !important; border-left: none !important; - border-bottom: 1px dotted rgba(255,255,255,0.5); + border-bottom: 1px solid rgba(255,255,255,0.5); border-top: none; padding-top: 0.25em; padding-bottom: 0.25em; + margin: 0; } .NotificationTitle { diff --git a/wire/modules/System/SystemNotifications/Notifications.js b/wire/modules/System/SystemNotifications/Notifications.js index 424e2073..afcf4033 100644 --- a/wire/modules/System/SystemNotifications/Notifications.js +++ b/wire/modules/System/SystemNotifications/Notifications.js @@ -17,6 +17,13 @@ var Notifications = { iconMessage: 'smile-o', iconWarning: 'meh-o', iconError: 'frown-o', + iconRemove: 'times-circle', + classCommon: 'NoticeItem', + classMessage: 'NoticeMessage', + classWarning: 'NoticeWarning', + classError: 'NoticeError', + classDebug: 'NoticeDebug', + classContainer: 'container', ghostDelay: 2000, ghostDelayError: 4000, ghostFadeSpeed: 'fast', @@ -273,11 +280,11 @@ var Notifications = { } if(qtyError > 0) { - $bug.addClass('NoticeError', 'slow').removeClass('NoticeWarning', 'slow'); + $bug.addClass(Notifications.options.classError, 'slow').removeClass(Notifications.options.classWarning, 'slow'); } else if(qtyWarning > 0) { - $bug.addClass('NoticeWarning', 'slow').removeClass('NoticeError', 'slow'); + $bug.addClass(Notifications.options.classWarning, 'slow').removeClass(Notifications.options.classError, 'slow'); } else { - $bug.removeClass('NoticeWarning NoticeError', 'slow'); + $bug.removeClass(Notifications.options.classWarning + ' ' + Notifications.options.classError, 'slow'); } }, @@ -389,7 +396,7 @@ var Notifications = { $li = $("
                  • "); } - $li.attr('id', notification.id); + $li.attr('id', notification.id).addClass(Notifications.options.classCommon); if(notification.expires > 0) { $li.attr('data-expires', notification.expires); } @@ -397,9 +404,9 @@ var Notifications = { var $icon = $("").addClass('fa fa-fw fa-' + notification.icon); var $title = $("").addClass('NotificationTitle').html(notification.title); var $p = $("

                    ").append($title).prepend(' ').prepend($icon); - var $div = $("
                    ").addClass('container').append($p); + var $div = $("
                    ").addClass(Notifications.options.classContainer).append($p); var $text = $("
                    ").addClass('NotificationText'); - var $rm = $(""); + var $rm = $(""); var addClass = ''; if(progressNext > 0) { @@ -422,10 +429,10 @@ var Notifications = { $title.append(" " + notification.when + ""); } - if(notification.flagNames.indexOf('debug') != -1) $li.addClass('NoticeDebug'); - if(notification.flagNames.indexOf('error') != -1) $li.addClass('NoticeError'); - else if(notification.flagNames.indexOf('warning') != -1) $li.addClass('NoticeWarning'); - else if(notification.flagNames.indexOf('message') != -1) $li.addClass('NoticeMessage'); + if(notification.flagNames.indexOf('debug') != -1) $li.addClass(Notifications.options.classDebug); + if(notification.flagNames.indexOf('error') != -1) $li.addClass(Notifications.options.classError); + else if(notification.flagNames.indexOf('warning') != -1) $li.addClass(Notifications.options.classWarning); + else if(notification.flagNames.indexOf('message') != -1) $li.addClass(Notifications.options.classMessage); if(notification.html.length > 0) { @@ -586,15 +593,15 @@ var Notifications = { var delay = Notifications.options.ghostDelay; if(notification.flagNames.indexOf('error') > -1) { - $ghost.addClass('NoticeError'); + $ghost.addClass(Notifications.options.classError); delay = Notifications.options.ghostDelayError; } else if(notification.flagNames.indexOf('warning') > -1) { - $ghost.addClass('NoticeWarning'); + $ghost.addClass(Notifications.options.classWarning); delay = Notifications.options.ghostDelayError; } else { - $ghost.addClass('NoticeMessage'); + $ghost.addClass(Notifications.options.classMessage); } Notifications.$ghosts.append($li.hide()); @@ -766,6 +773,8 @@ var Notifications = { Notifications.$bug = $("#NotificationBug"); Notifications.$list = $("#NotificationList"); Notifications.$ghosts = $("#NotificationGhosts"); + + if(!Notifications.$bug.length) return; Notifications.$menu.hide(); Notifications.$bug.click(Notifications.clickBug); diff --git a/wire/modules/System/SystemNotifications/Notifications.min.js b/wire/modules/System/SystemNotifications/Notifications.min.js index c962f5aa..d4ebc618 100644 --- a/wire/modules/System/SystemNotifications/Notifications.min.js +++ b/wire/modules/System/SystemNotifications/Notifications.min.js @@ -1 +1 @@ -var Notifications={options:{ajaxURL:"./",version:1,reverse:0,updateLast:0,updateDelay:5000,updateDelayFast:1550,iconMessage:"smile-o",iconWarning:"meh-o",iconError:"frown-o",ghostDelay:2000,ghostDelayError:4000,ghostFadeSpeed:"fast",ghostOpacity:0.9,ghostLimit:20,processKey:"",i18n:{sec:"sec",secs:"secs",min:"min",mins:"mins",hour:"hour",hours:"hours",day:"day",days:"days",expires:"expires",now:"now",fromNow:"from now",ago:"ago"}},updateTimeout:null,renderTimeout:null,timerTimeout:null,updating:false,runtime:[],numRender:0,numEmptyRequests:0,ghostsActive:0,currentDelay:0,turbo:false,timeNow:0,useSession:false,$menu:null,$bug:null,$list:null,relativeTime:function(a){var d="";if(a==0){return d}var c=Notifications.options.i18n;var b=a>0;a=Math.abs(a);if(a>1&&a<60){d=a+" "+(a==1?c.sec:c.secs)}else{if(a>=60&&a<3600){d=Math.floor(a/60);d+=" "+(d==1?c.min:c.mins)}else{if(a>=3600&&a<86400){d=Math.floor(a/3600);d+=" "+(d==1?c.hour:c.hours)}else{if(a>=86400){d=Math.floor(a/86400);d+=" "+(d==1?c.day:c.days)}}}}d+=" ";if(b){if(a<3){d=c.now}}else{if(a<3){d=c.now}}return d},setTurboMode:function(a){if(a){if(Notifications.currentDelay!=Notifications.options.updateDelayFast){Notifications.currentDelay=Notifications.options.updateDelayFast;Notifications.update()}}else{Notifications.currentDelay=Notifications.options.updateDelay}},_updateItemTime:function(h,c){var f=h.find("small.created");var e="";if(f.length>0){var g=parseInt(f.attr("data-created"));var d=c-g;e=Notifications.relativeTime(d,true)}var a=h.attr("data-expires");if(a){a=parseInt(a);if(a>0&&a<=c){h.slideUp("fast",function(){Notifications._remove(h)})}else{if(e.length>0){e+=" / "}var b=Notifications.options.i18n.expires+" "+Notifications.relativeTime(c-a);if(Math.abs(c-a)<10){b=""+b+""}e+=b}}f.html(e)},_updateTime:function(){if(Notifications.timeNow==0){return}Notifications.$list.children("li").each(function(){Notifications._updateItemTime($(this),Notifications.timeNow)})},update:function(){if(Notifications.updating){clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",Notifications.currentDelay);return false}Notifications.updating=true;var c="";var b=Notifications.$list.find("li.removed");b.each(function(){c+=$(this).attr("id")+",";$(this).remove()});var a="./?Notifications=update&time="+Notifications.options.updateLast;if(c.length){a+="&rm="+c}if(Notifications.useSession&&Notifications.options.processKey.length){a+="&processKey="+Notifications.options.processKey+"."+sessionStorage.pwWindowName}$.getJSON(a,function(d){Notifications._update(d);clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",Notifications.currentDelay);Notifications.updating=false})},_update:function(c){var b=parseInt(c.time);var a=false;var g=c.notifications.length;var e=[];if(g>0){Notifications.numEmptyRequests=0}else{Notifications.numEmptyRequests++;if(Notifications.numEmptyRequests>2){Notifications.setTurboMode(false)}}if(b>0){Notifications.timeNow=b}Notifications.options.updateLast=Notifications.timeNow;for(var f=0;f-1){e[e.length]=d}else{Notifications._add(d,!c.runtime);if(d.flagNames.indexOf("annoy")>-1){a=true}}if(d.flagNames.indexOf("no-ghost")<0){Notifications._ghost(d,f)}}if(a&&!Notifications.$menu.hasClass("open")){Notifications.$bug.click()}if(a){window.scrollTo(0,0)}if(!Notifications.$menu.hasClass("open")){Notifications._updateTime()}Notifications._updateBug();if(e.length){for(var f=0;f0){d.addClass("NoticeError","slow").removeClass("NoticeWarning","slow")}else{if(b>0){d.addClass("NoticeWarning","slow").removeClass("NoticeError","slow")}else{d.removeClass("NoticeWarning NoticeError","slow")}}},_updateBugQty:function(b){var c=Notifications.$bug;var d=c.children(".qty");var a=b>99?"99+":b;c.attr("class",c.attr("class").replace(/qty\d+\s*/g,""));c.addClass("qty"+b);d.text(a);if(b==0){c.fadeOut()}else{if(!c.is(":visible")){c.fadeIn()}}c.attr("data-qty",b)},add:function(a){var b=Notifications.runtime.length;a.addClass="runtime";a.runtime=true;Notifications.runtime[b]=a},render:function(){Notifications.renderTimeout=setTimeout(function(){var a=0;var b=0;var c=0;$(Notifications.runtime).each(function(f,e){if(e.flagNames.indexOf("error")!=-1){a++}else{if(e.flagNames.indexOf("warning")!=-1){b++}else{c++}}});var d={qty:Notifications.runtime.length,qtyNew:0,qtyMessage:c,qtyWarning:b,qtyError:a,notifications:Notifications.runtime,runtime:true};Notifications._update(d,true);if(Notifications.$list.find(".NotificationProgress").length>0){Notifications.setTurboMode(true)}},250);Notifications.numRender++},_add:function(a,b){var o=false;var d=false;var j=Notifications.$list.children("#"+a.id);var q=parseInt(a.progress);var m=0;var n=null;if(j.length>0){o=true;b=false;d=j.hasClass("open");var i=j.find(".NotificationProgress");if(i.length>0){m=parseInt(i.text())}n=j.find("small.created");j.empty()}else{j=$("
                  • ")}j.attr("id",a.id);if(a.expires>0){j.attr("data-expires",a.expires)}var g=$("").addClass("fa fa-fw fa-"+a.icon);var k=$("").addClass("NotificationTitle").html(a.title);var f=$("

                    ").append(k).prepend(" ").prepend(g);var h=$("
                    ").addClass("container").append(f);var l=$("
                    ").addClass("NotificationText");var c=$("");var e="";if(q>0){j.prepend(Notifications._progress(k,q,m));if(q<100){j.addClass("NotificationHasProgress","normal")}}if("addClass" in a&&a.addClass.length>0){e=a.addClass;j.addClass(e)}if(n!==null&&n.length){k.append(" ").append(n)}else{if("when" in a&&a.created>0){k.append(" "+a.when+"")}}if(a.flagNames.indexOf("debug")!=-1){j.addClass("NoticeDebug")}if(a.flagNames.indexOf("error")!=-1){j.addClass("NoticeError")}else{if(a.flagNames.indexOf("warning")!=-1){j.addClass("NoticeWarning")}else{if(a.flagNames.indexOf("message")!=-1){j.addClass("NoticeMessage")}}}if(a.html.length>0){l.html(a.html);var p=$("");k.append(" ").append(p);k.click(function(){if(j.hasClass("open")){j.removeClass("open");l.slideUp("fast").removeClass("open");p.removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-right")}else{l.slideDown("fast").addClass("open");j.addClass("open");p.removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-down")}});h.append(l);if(d||a.flagNames.indexOf("open")!=-1){if(!d){k.click()}else{j.addClass("open");l.show().addClass("open")}}}c.on("click",function(){Notifications._remove(j)});f.prepend(c);j.append(h);if(b){j.hide();if(Notifications.options.reverse){Notifications.$list.append(j)}else{Notifications.$list.prepend(j)}j.slideDown().effect("highlight",500)}else{if(o){j.show()}else{Notifications.$list.append(j)}}},_remove:function(b){b.addClass("removed").hide();var a=b.siblings(":visible").length;Notifications._updateBugQty(a);clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",1000)},_progress:function(d,a,c){var b=$("
                    ").addClass("NotificationProgress").html(""+a+"%").css("width",c+"%").hide();if(a>c){var e=c==0?Notifications.currentDelay/1.4:1750;var f="linear";if(a==100){e=750;f="swing"}else{if(c==0){f="swing"}}if(a>0&&a<=100){b.show().animate({width:a+"%"},{duration:e,easing:f,complete:function(){if(a>=100){b.fadeOut("slow",function(){d.parents(".NotificationHasProgress").removeClass("NotificationHasProgress","slow")})}}})}else{if(a>=100){if(Notifications.$list.find(".NotificationHasProgress").length==0){Notifications.setTurboMode(false)}}else{b.css("width",a+"%").show()}}b.height("100%")}d.append(" "+a+"%");return b},_ghost:function(d,c){if(d.progress>0&&d.progress<100){return}if(Notifications.$menu.hasClass("open")){return}var g=$('');var i=$("
                    ").append(g).append(" "+$(""+d.title+"").text());var h=$("
                  • ").append(i);var e=Notifications.options.ghostDelay;if(d.flagNames.indexOf("error")>-1){i.addClass("NoticeError");e=Notifications.options.ghostDelayError}else{if(d.flagNames.indexOf("warning")>-1){i.addClass("NoticeWarning");e=Notifications.options.ghostDelayError}else{i.addClass("NoticeMessage")}}Notifications.$ghosts.append(h.hide());Notifications.ghostsActive++;var j=Notifications.options.ghostFadeSpeed;var f=Notifications.options.ghostOpacity;var b=100*c;var a=$(window).height();if(j.length==0){b=200*c}setTimeout(function(){if(j.length>0){h.fadeTo(j,f)}else{h.show().css("opacity",f)}var l=h.offset().top;var k=h.height();if(l+k>(a/2)){Notifications.$ghosts.animate({top:"-="+(k+3)},"fast")}setTimeout(function(){var m=function(){h.addClass("removed");Notifications.ghostsActive--;if(Notifications.ghostsActive==0){Notifications.$ghosts.children("li").remove()}};if(j.length>0){h.fadeTo(j,0.01,m)}else{h.css("opacity",0.01);m()}},e)},b);d.ghostShown=true},clickBug:function(){var a=Notifications.$menu;if(a.hasClass("open")){a.slideUp("fast",function(){a.removeClass("open");Notifications.$bug.removeClass("open");clearTimeout(Notifications.timerTimeout)})}else{if(!a.hasClass("init")){a.prependTo($("body"));a.addClass("init")}a.slideDown("fast",function(){a.addClass("open");Notifications.$bug.addClass("open");Notifications._startTimeUpdater()});Notifications.$ghosts.find("li").hide()}return false},_startTimeUpdater:function(){if(Notifications.timeNow>0){Notifications.timeNow+=1}Notifications._updateTime();Notifications.timerTimeout=setTimeout("Notifications._startTimeUpdater()",1000)},_show:function(d,f,b,c,a){var e={id:0,title:f,from:"",created:0,modified:0,when:"now",href:a,icon:c,flags:0,flagNames:d+" notice",progress:0,html:b,qty:1};Notifications.add(e);if(Notifications.numRender>0){Notifications.render()}},message:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconMessage}if(typeof a=="undefined"){a=""}Notifications._show("message",d,b,c,a)},warning:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconWarning}if(typeof a=="undefined"){a=""}Notifications._show("warning",d,b,c,a)},error:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconError}if(typeof a=="undefined"){a=""}Notifications._show("error",d,b,c,a)},init:function(a){$.extend(Notifications.options,a);Notifications.currentDelay=Notifications.options.updateDelay;Notifications.$menu=$("#NotificationMenu");Notifications.$bug=$("#NotificationBug");Notifications.$list=$("#NotificationList");Notifications.$ghosts=$("#NotificationGhosts");Notifications.$menu.hide();Notifications.$bug.click(Notifications.clickBug);Notifications.useSession=typeof sessionStorage!="undefined";Notifications.updateTimeout=setTimeout(Notifications.update,Notifications.currentDelay);$("#ProcessPageSearchForm input").dblclick(function(b){Notifications.message("ProcessWire Notifications v"+Notifications.options.version,"Grab a coffee and come and visit us at the ProcessWire support forums.

                    ","coffee fa-spin");return false});$(document).on("pw-modal-opened",function(){if(Notifications.$bug.is(":visible")){Notifications.$bug.fadeOut().addClass("hidden-for-modal")}if(Notifications.$menu.is(":visible")){Notifications.$menu.hide().addClass("hidden-for-modal")}}).on("pw-modal-closed",function(){if(Notifications.$bug.hasClass("hidden-for-modal")){Notifications.$bug.fadeIn().removeClass("hidden-for-modal")}if(Notifications.$menu.hasClass("hidden-for-modal")){Notifications.$menu.slideDown().removeClass("hidden-for-modal")}});if(Notifications.useSession&&Notifications.options.processKey.length){if(typeof sessionStorage.pwWindowName=="undefined"||sessionStorage.pwWindowName.indexOf("PW")!==0){sessionStorage.pwWindowName="PW"+Math.floor(Math.random()*65536).toString()+Math.floor(Math.random()*65536).toString()}}}}; \ No newline at end of file +var Notifications={options:{ajaxURL:"./",version:1,reverse:0,updateLast:0,updateDelay:5000,updateDelayFast:1550,iconMessage:"smile-o",iconWarning:"meh-o",iconError:"frown-o",iconRemove:"times-circle",classCommon:"NoticeItem",classMessage:"NoticeMessage",classWarning:"NoticeWarning",classError:"NoticeError",classDebug:"NoticeDebug",classContainer:"container",ghostDelay:2000,ghostDelayError:4000,ghostFadeSpeed:"fast",ghostOpacity:0.9,ghostLimit:20,processKey:"",i18n:{sec:"sec",secs:"secs",min:"min",mins:"mins",hour:"hour",hours:"hours",day:"day",days:"days",expires:"expires",now:"now",fromNow:"from now",ago:"ago"}},updateTimeout:null,renderTimeout:null,timerTimeout:null,updating:false,runtime:[],numRender:0,numEmptyRequests:0,ghostsActive:0,currentDelay:0,turbo:false,timeNow:0,useSession:false,$menu:null,$bug:null,$list:null,relativeTime:function(a){var d="";if(a==0){return d}var c=Notifications.options.i18n;var b=a>0;a=Math.abs(a);if(a>1&&a<60){d=a+" "+(a==1?c.sec:c.secs)}else{if(a>=60&&a<3600){d=Math.floor(a/60);d+=" "+(d==1?c.min:c.mins)}else{if(a>=3600&&a<86400){d=Math.floor(a/3600);d+=" "+(d==1?c.hour:c.hours)}else{if(a>=86400){d=Math.floor(a/86400);d+=" "+(d==1?c.day:c.days)}}}}d+=" ";if(b){if(a<3){d=c.now}}else{if(a<3){d=c.now}}return d},setTurboMode:function(a){if(a){if(Notifications.currentDelay!=Notifications.options.updateDelayFast){Notifications.currentDelay=Notifications.options.updateDelayFast;Notifications.update()}}else{Notifications.currentDelay=Notifications.options.updateDelay}},_updateItemTime:function(h,c){var f=h.find("small.created");var e="";if(f.length>0){var g=parseInt(f.attr("data-created"));var d=c-g;e=Notifications.relativeTime(d,true)}var a=h.attr("data-expires");if(a){a=parseInt(a);if(a>0&&a<=c){h.slideUp("fast",function(){Notifications._remove(h)})}else{if(e.length>0){e+=" / "}var b=Notifications.options.i18n.expires+" "+Notifications.relativeTime(c-a);if(Math.abs(c-a)<10){b=""+b+""}e+=b}}f.html(e)},_updateTime:function(){if(Notifications.timeNow==0){return}Notifications.$list.children("li").each(function(){Notifications._updateItemTime($(this),Notifications.timeNow)})},update:function(){if(Notifications.updating){clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",Notifications.currentDelay);return false}Notifications.updating=true;var c="";var b=Notifications.$list.find("li.removed");b.each(function(){c+=$(this).attr("id")+",";$(this).remove()});var a="./?Notifications=update&time="+Notifications.options.updateLast;if(c.length){a+="&rm="+c}if(Notifications.useSession&&Notifications.options.processKey.length){a+="&processKey="+Notifications.options.processKey+"."+sessionStorage.pwWindowName}$.getJSON(a,function(d){Notifications._update(d);clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",Notifications.currentDelay);Notifications.updating=false})},_update:function(c){var b=parseInt(c.time);var a=false;var g=c.notifications.length;var e=[];if(g>0){Notifications.numEmptyRequests=0}else{Notifications.numEmptyRequests++;if(Notifications.numEmptyRequests>2){Notifications.setTurboMode(false)}}if(b>0){Notifications.timeNow=b}Notifications.options.updateLast=Notifications.timeNow;for(var f=0;f-1){e[e.length]=d}else{Notifications._add(d,!c.runtime);if(d.flagNames.indexOf("annoy")>-1){a=true}}if(d.flagNames.indexOf("no-ghost")<0){Notifications._ghost(d,f)}}if(a&&!Notifications.$menu.hasClass("open")){Notifications.$bug.click()}if(a){window.scrollTo(0,0)}if(!Notifications.$menu.hasClass("open")){Notifications._updateTime()}Notifications._updateBug();if(e.length){for(var f=0;f0){d.addClass(Notifications.options.classError,"slow").removeClass(Notifications.options.classWarning,"slow")}else{if(b>0){d.addClass(Notifications.options.classWarning,"slow").removeClass(Notifications.options.classError,"slow")}else{d.removeClass(Notifications.options.classWarning+" "+Notifications.options.classError,"slow")}}},_updateBugQty:function(b){var c=Notifications.$bug;var d=c.children(".qty");var a=b>99?"99+":b;c.attr("class",c.attr("class").replace(/qty\d+\s*/g,""));c.addClass("qty"+b);d.text(a);if(b==0){c.fadeOut()}else{if(!c.is(":visible")){c.fadeIn()}}c.attr("data-qty",b)},add:function(a){var b=Notifications.runtime.length;a.addClass="runtime";a.runtime=true;Notifications.runtime[b]=a},render:function(){Notifications.renderTimeout=setTimeout(function(){var a=0;var b=0;var c=0;$(Notifications.runtime).each(function(f,e){if(e.flagNames.indexOf("error")!=-1){a++}else{if(e.flagNames.indexOf("warning")!=-1){b++}else{c++}}});var d={qty:Notifications.runtime.length,qtyNew:0,qtyMessage:c,qtyWarning:b,qtyError:a,notifications:Notifications.runtime,runtime:true};Notifications._update(d,true);if(Notifications.$list.find(".NotificationProgress").length>0){Notifications.setTurboMode(true)}},250);Notifications.numRender++},_add:function(a,b){var o=false;var d=false;var j=Notifications.$list.children("#"+a.id);var q=parseInt(a.progress);var m=0;var n=null;if(j.length>0){o=true;b=false;d=j.hasClass("open");var i=j.find(".NotificationProgress");if(i.length>0){m=parseInt(i.text())}n=j.find("small.created");j.empty()}else{j=$("
                  • ")}j.attr("id",a.id).addClass(Notifications.options.classCommon);if(a.expires>0){j.attr("data-expires",a.expires)}var g=$("").addClass("fa fa-fw fa-"+a.icon);var k=$("").addClass("NotificationTitle").html(a.title);var f=$("

                    ").append(k).prepend(" ").prepend(g);var h=$("
                    ").addClass(Notifications.options.classContainer).append(f);var l=$("
                    ").addClass("NotificationText");var c=$("");var e="";if(q>0){j.prepend(Notifications._progress(k,q,m));if(q<100){j.addClass("NotificationHasProgress","normal")}}if("addClass" in a&&a.addClass.length>0){e=a.addClass;j.addClass(e)}if(n!==null&&n.length){k.append(" ").append(n)}else{if("when" in a&&a.created>0){k.append(" "+a.when+"")}}if(a.flagNames.indexOf("debug")!=-1){j.addClass(Notifications.options.classDebug)}if(a.flagNames.indexOf("error")!=-1){j.addClass(Notifications.options.classError)}else{if(a.flagNames.indexOf("warning")!=-1){j.addClass(Notifications.options.classWarning)}else{if(a.flagNames.indexOf("message")!=-1){j.addClass(Notifications.options.classMessage)}}}if(a.html.length>0){l.html(a.html);var p=$("");k.append(" ").append(p);k.click(function(){if(j.hasClass("open")){j.removeClass("open");l.slideUp("fast").removeClass("open");p.removeClass("fa-chevron-circle-down").addClass("fa-chevron-circle-right")}else{l.slideDown("fast").addClass("open");j.addClass("open");p.removeClass("fa-chevron-circle-right").addClass("fa-chevron-circle-down")}});h.append(l);if(d||a.flagNames.indexOf("open")!=-1){if(!d){k.click()}else{j.addClass("open");l.show().addClass("open")}}}c.on("click",function(){Notifications._remove(j)});f.prepend(c);j.append(h);if(b){j.hide();if(Notifications.options.reverse){Notifications.$list.append(j)}else{Notifications.$list.prepend(j)}j.slideDown().effect("highlight",500)}else{if(o){j.show()}else{Notifications.$list.append(j)}}},_remove:function(b){b.addClass("removed").hide();var a=b.siblings(":visible").length;Notifications._updateBugQty(a);clearTimeout(Notifications.updateTimeout);Notifications.updateTimeout=setTimeout("Notifications.update()",1000)},_progress:function(d,a,c){var b=$("
                    ").addClass("NotificationProgress").html(""+a+"%").css("width",c+"%").hide();if(a>c){var e=c==0?Notifications.currentDelay/1.4:1750;var f="linear";if(a==100){e=750;f="swing"}else{if(c==0){f="swing"}}if(a>0&&a<=100){b.show().animate({width:a+"%"},{duration:e,easing:f,complete:function(){if(a>=100){b.fadeOut("slow",function(){d.parents(".NotificationHasProgress").removeClass("NotificationHasProgress","slow")})}}})}else{if(a>=100){if(Notifications.$list.find(".NotificationHasProgress").length==0){Notifications.setTurboMode(false)}}else{b.css("width",a+"%").show()}}b.height("100%")}d.append(" "+a+"%");return b},_ghost:function(d,c){if(d.progress>0&&d.progress<100){return}if(Notifications.$menu.hasClass("open")){return}var g=$('');var i=$("
                    ").append(g).append(" "+$(""+d.title+"").text());var h=$("
                  • ").append(i);var e=Notifications.options.ghostDelay;if(d.flagNames.indexOf("error")>-1){i.addClass(Notifications.options.classError);e=Notifications.options.ghostDelayError}else{if(d.flagNames.indexOf("warning")>-1){i.addClass(Notifications.options.classWarning);e=Notifications.options.ghostDelayError}else{i.addClass(Notifications.options.classMessage)}}Notifications.$ghosts.append(h.hide());Notifications.ghostsActive++;var j=Notifications.options.ghostFadeSpeed;var f=Notifications.options.ghostOpacity;var b=100*c;var a=$(window).height();if(j.length==0){b=200*c}setTimeout(function(){if(j.length>0){h.fadeTo(j,f)}else{h.show().css("opacity",f)}var l=h.offset().top;var k=h.height();if(l+k>(a/2)){Notifications.$ghosts.animate({top:"-="+(k+3)},"fast")}setTimeout(function(){var m=function(){h.addClass("removed");Notifications.ghostsActive--;if(Notifications.ghostsActive==0){Notifications.$ghosts.children("li").remove()}};if(j.length>0){h.fadeTo(j,0.01,m)}else{h.css("opacity",0.01);m()}},e)},b);d.ghostShown=true},clickBug:function(){var a=Notifications.$menu;if(a.hasClass("open")){a.slideUp("fast",function(){a.removeClass("open");Notifications.$bug.removeClass("open");clearTimeout(Notifications.timerTimeout)})}else{if(!a.hasClass("init")){a.prependTo($("body"));a.addClass("init")}a.slideDown("fast",function(){a.addClass("open");Notifications.$bug.addClass("open");Notifications._startTimeUpdater()});Notifications.$ghosts.find("li").hide()}return false},_startTimeUpdater:function(){if(Notifications.timeNow>0){Notifications.timeNow+=1}Notifications._updateTime();Notifications.timerTimeout=setTimeout("Notifications._startTimeUpdater()",1000)},_show:function(d,f,b,c,a){var e={id:0,title:f,from:"",created:0,modified:0,when:"now",href:a,icon:c,flags:0,flagNames:d+" notice",progress:0,html:b,qty:1};Notifications.add(e);if(Notifications.numRender>0){Notifications.render()}},message:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconMessage}if(typeof a=="undefined"){a=""}Notifications._show("message",d,b,c,a)},warning:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconWarning}if(typeof a=="undefined"){a=""}Notifications._show("warning",d,b,c,a)},error:function(d,b,c,a){if(typeof b=="undefined"){b=""}if(typeof c=="undefined"){c=Notifications.options.iconError}if(typeof a=="undefined"){a=""}Notifications._show("error",d,b,c,a)},init:function(a){$.extend(Notifications.options,a);Notifications.currentDelay=Notifications.options.updateDelay;Notifications.$menu=$("#NotificationMenu");Notifications.$bug=$("#NotificationBug");Notifications.$list=$("#NotificationList");Notifications.$ghosts=$("#NotificationGhosts");if(!Notifications.$bug.length){return}Notifications.$menu.hide();Notifications.$bug.click(Notifications.clickBug);Notifications.useSession=typeof sessionStorage!="undefined";Notifications.updateTimeout=setTimeout(Notifications.update,Notifications.currentDelay);$("#ProcessPageSearchForm input").dblclick(function(b){Notifications.message("ProcessWire Notifications v"+Notifications.options.version,"Grab a coffee and come and visit us at the ProcessWire support forums.

                    ","coffee fa-spin");return false});$(document).on("pw-modal-opened",function(){if(Notifications.$bug.is(":visible")){Notifications.$bug.fadeOut().addClass("hidden-for-modal")}if(Notifications.$menu.is(":visible")){Notifications.$menu.hide().addClass("hidden-for-modal")}}).on("pw-modal-closed",function(){if(Notifications.$bug.hasClass("hidden-for-modal")){Notifications.$bug.fadeIn().removeClass("hidden-for-modal")}if(Notifications.$menu.hasClass("hidden-for-modal")){Notifications.$menu.slideDown().removeClass("hidden-for-modal")}});if(Notifications.useSession&&Notifications.options.processKey.length){if(typeof sessionStorage.pwWindowName=="undefined"||sessionStorage.pwWindowName.indexOf("PW")!==0){sessionStorage.pwWindowName="PW"+Math.floor(Math.random()*65536).toString()+Math.floor(Math.random()*65536).toString()}}}}; \ No newline at end of file diff --git a/wire/modules/System/SystemNotifications/SystemNotifications.module b/wire/modules/System/SystemNotifications/SystemNotifications.module index 2e878525..cdc36b56 100644 --- a/wire/modules/System/SystemNotifications/SystemNotifications.module +++ b/wire/modules/System/SystemNotifications/SystemNotifications.module @@ -67,6 +67,7 @@ class SystemNotifications extends WireData implements Module { // hook method to access notifications, in case field name ever needs to change for some reason $this->addHook('User::notifications', $this, 'hookUserNotifications'); + $this->set('disabled', false); } /** @@ -291,6 +292,8 @@ class SystemNotifications extends WireData implements Module { * */ public function hookAdminThemeGetExtraMarkup($event) { + + if($this->disabled) return; $config = $this->wire('config'); $url = $config->urls->SystemNotifications . 'Notifications'; @@ -326,6 +329,17 @@ class SystemNotifications extends WireData implements Module { } $options['reverse'] = (bool) ((int) $options['reverse']); + // options specified in $config->SystemNotifications + $configDefaults = array( + 'classMessage' => 'NoticeMessage', + 'classWarning' => 'NoticeWarning', + 'classError' => 'NoticeError', + 'classContainer' => 'container', + ); + $configOptions = $this->wire('config')->SystemNotifications; + if(!is_array($configOptions)) $configOptions = array(); + $options = array_merge($options, $configDefaults, $configOptions); + $textdomain = '/wire/core/Functions.php'; $options['i18n'] = array( 'sec' => __('sec', $textdomain), @@ -436,7 +450,7 @@ class SystemNotifications extends WireData implements Module { $extras = $event->return; $extras['body'] .= $out; - $extras['masthead'] .= + $extras['masthead'] .= "
                    " . "$qty" . "" .