diff --git a/CHANGELOG.md b/CHANGELOG.md index eef7fe2dc..f007dbe8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +* **Build 130** (2014-07-27) + - Complete redesign of Settings area. + - Added markdown Twig filter `{{ 'I am **markdown**'|md }}`. + * **Build 129** (2014-07-25) - Fixes a bug where the active theme is not editable in the back-end. - Added a new console command `october:util` for performing utility and maintenance tasks. diff --git a/modules/backend/ServiceProvider.php b/modules/backend/ServiceProvider.php index 34aea94e1..9f3dd231d 100644 --- a/modules/backend/ServiceProvider.php +++ b/modules/backend/ServiceProvider.php @@ -101,7 +101,8 @@ class ServiceProvider extends ModuleServiceProvider 'icon' => 'icon-user', 'url' => Backend::URL('backend/users/myaccount'), 'order' => 400, - 'context' => 'mysettings' + 'context' => 'mysettings', + 'keywords' => 'backend::lang.myaccount.menu_keywords', ], ]); }); diff --git a/modules/backend/assets/css/october.css b/modules/backend/assets/css/october.css index 25bb5b602..fba403501 100644 --- a/modules/backend/assets/css/october.css +++ b/modules/backend/assets/css/october.css @@ -1945,6 +1945,7 @@ select[multiple].input-lg { border: 1px solid transparent; white-space: nowrap; padding: 9px 11px; + padding: 9px 16.5px; font-size: 14px; line-height: 1.428571429; border-radius: 2px; @@ -2264,6 +2265,7 @@ fieldset[disabled] .btn-link:focus { .btn-lg, .btn-group-lg > .btn { padding: 10px 16px; + padding: 10px 24px; font-size: 18px; line-height: 1.33; border-radius: 6px; @@ -2271,6 +2273,7 @@ fieldset[disabled] .btn-link:focus { .btn-sm, .btn-group-sm > .btn { padding: 5px 10px; + padding: 5px 15px; font-size: 12px; line-height: 1.5; border-radius: 3px; @@ -2278,6 +2281,7 @@ fieldset[disabled] .btn-link:focus { .btn-xs, .btn-group-xs > .btn { padding: 1px 5px; + padding: 1px 7.5px; font-size: 12px; line-height: 1.5; border-radius: 3px; @@ -5406,6 +5410,8 @@ a .icon-flip-vertical:before { .oc-icon-video-camera:before { content: "\f03d"; } +.oc-icon-photo:before, +.oc-icon-image:before, .oc-icon-picture-o:before { content: "\f03e"; } @@ -5769,6 +5775,8 @@ a .icon-flip-vertical:before { .oc-icon-square:before { content: "\f0c8"; } +.oc-icon-navicon:before, +.oc-icon-reorder:before, .oc-icon-bars:before { content: "\f0c9"; } @@ -5828,13 +5836,13 @@ a .icon-flip-vertical:before { content: "\f0dc"; } .oc-icon-sort-down:before, -.oc-icon-sort-asc:before { - content: "\f0de"; -} -.oc-icon-sort-up:before, .oc-icon-sort-desc:before { content: "\f0dd"; } +.oc-icon-sort-up:before, +.oc-icon-sort-asc:before { + content: "\f0de"; +} .oc-icon-envelope:before { content: "\f0e0"; } @@ -6022,12 +6030,10 @@ a .icon-flip-vertical:before { .oc-icon-code:before { content: "\f121"; } +.oc-icon-mail-reply-all:before, .oc-icon-reply-all:before { content: "\f122"; } -.oc-icon-mail-reply-all:before { - content: "\f122"; -} .oc-icon-star-half-empty:before, .oc-icon-star-half-full:before, .oc-icon-star-half-o:before { @@ -6373,6 +6379,238 @@ a .icon-flip-vertical:before { .oc-icon-plus-square-o:before { content: "\f196"; } +.oc-icon-space-shuttle:before { + content: "\f197"; +} +.oc-icon-slack:before { + content: "\f198"; +} +.oc-icon-envelope-square:before { + content: "\f199"; +} +.oc-icon-wordpress:before { + content: "\f19a"; +} +.oc-icon-openid:before { + content: "\f19b"; +} +.oc-icon-institution:before, +.oc-icon-bank:before, +.oc-icon-university:before { + content: "\f19c"; +} +.oc-icon-mortar-board:before, +.oc-icon-graduation-cap:before { + content: "\f19d"; +} +.oc-icon-yahoo:before { + content: "\f19e"; +} +.oc-icon-google:before { + content: "\f1a0"; +} +.oc-icon-reddit:before { + content: "\f1a1"; +} +.oc-icon-reddit-square:before { + content: "\f1a2"; +} +.oc-icon-stumbleupon-circle:before { + content: "\f1a3"; +} +.oc-icon-stumbleupon:before { + content: "\f1a4"; +} +.oc-icon-delicious:before { + content: "\f1a5"; +} +.oc-icon-digg:before { + content: "\f1a6"; +} +.oc-icon-pied-piper-square:before, +.oc-icon-pied-piper:before { + content: "\f1a7"; +} +.oc-icon-pied-piper-alt:before { + content: "\f1a8"; +} +.oc-icon-drupal:before { + content: "\f1a9"; +} +.oc-icon-joomla:before { + content: "\f1aa"; +} +.oc-icon-language:before { + content: "\f1ab"; +} +.oc-icon-fax:before { + content: "\f1ac"; +} +.oc-icon-building:before { + content: "\f1ad"; +} +.oc-icon-child:before { + content: "\f1ae"; +} +.oc-icon-paw:before { + content: "\f1b0"; +} +.oc-icon-spoon:before { + content: "\f1b1"; +} +.oc-icon-cube:before { + content: "\f1b2"; +} +.oc-icon-cubes:before { + content: "\f1b3"; +} +.oc-icon-behance:before { + content: "\f1b4"; +} +.oc-icon-behance-square:before { + content: "\f1b5"; +} +.oc-icon-steam:before { + content: "\f1b6"; +} +.oc-icon-steam-square:before { + content: "\f1b7"; +} +.oc-icon-recycle:before { + content: "\f1b8"; +} +.oc-icon-automobile:before, +.oc-icon-car:before { + content: "\f1b9"; +} +.oc-icon-cab:before, +.oc-icon-taxi:before { + content: "\f1ba"; +} +.oc-icon-tree:before { + content: "\f1bb"; +} +.oc-icon-spotify:before { + content: "\f1bc"; +} +.oc-icon-deviantart:before { + content: "\f1bd"; +} +.oc-icon-soundcloud:before { + content: "\f1be"; +} +.oc-icon-database:before { + content: "\f1c0"; +} +.oc-icon-file-pdf-o:before { + content: "\f1c1"; +} +.oc-icon-file-word-o:before { + content: "\f1c2"; +} +.oc-icon-file-excel-o:before { + content: "\f1c3"; +} +.oc-icon-file-powerpoint-o:before { + content: "\f1c4"; +} +.oc-icon-file-photo-o:before, +.oc-icon-file-picture-o:before, +.oc-icon-file-image-o:before { + content: "\f1c5"; +} +.oc-icon-file-zip-o:before, +.oc-icon-file-archive-o:before { + content: "\f1c6"; +} +.oc-icon-file-sound-o:before, +.oc-icon-file-audio-o:before { + content: "\f1c7"; +} +.oc-icon-file-movie-o:before, +.oc-icon-file-video-o:before { + content: "\f1c8"; +} +.oc-icon-file-code-o:before { + content: "\f1c9"; +} +.oc-icon-vine:before { + content: "\f1ca"; +} +.oc-icon-codepen:before { + content: "\f1cb"; +} +.oc-icon-jsfiddle:before { + content: "\f1cc"; +} +.oc-icon-life-bouy:before, +.oc-icon-life-saver:before, +.oc-icon-support:before, +.oc-icon-life-ring:before { + content: "\f1cd"; +} +.oc-icon-circle-o-notch:before { + content: "\f1ce"; +} +.oc-icon-ra:before, +.oc-icon-rebel:before { + content: "\f1d0"; +} +.oc-icon-ge:before, +.oc-icon-empire:before { + content: "\f1d1"; +} +.oc-icon-git-square:before { + content: "\f1d2"; +} +.oc-icon-git:before { + content: "\f1d3"; +} +.oc-icon-hacker-news:before { + content: "\f1d4"; +} +.oc-icon-tencent-weibo:before { + content: "\f1d5"; +} +.oc-icon-qq:before { + content: "\f1d6"; +} +.oc-icon-wechat:before, +.oc-icon-weixin:before { + content: "\f1d7"; +} +.oc-icon-send:before, +.oc-icon-paper-plane:before { + content: "\f1d8"; +} +.oc-icon-send-o:before, +.oc-icon-paper-plane-o:before { + content: "\f1d9"; +} +.oc-icon-history:before { + content: "\f1da"; +} +.oc-icon-circle-thin:before { + content: "\f1db"; +} +.oc-icon-header:before { + content: "\f1dc"; +} +.oc-icon-paragraph:before { + content: "\f1dd"; +} +.oc-icon-sliders:before { + content: "\f1de"; +} +.oc-icon-share-alt:before { + content: "\f1e0"; +} +.oc-icon-share-alt-square:before { + content: "\f1e1"; +} +.oc-icon-bomb:before { + content: "\f1e2"; +} [class^="flag-"], [class*=" flag-"] { background: url(../images/flag-icons-small.png) no-repeat; @@ -8071,6 +8309,9 @@ label { transition: none; -webkit-box-shadow: none; box-shadow: none; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; } .form-control:focus { -webkit-box-shadow: none; @@ -8268,11 +8509,10 @@ label { .field-recordfinder .btn { background: transparent; position: absolute; - right: 0; + right: -2px; top: 50%; margin-top: -44px; height: 88px; - width: 36px; color: #8c8c8c; } .field-recordfinder .btn i { @@ -8425,16 +8665,17 @@ label { border-radius: 2px; } .switch-field .field-switch { - padding-left: 105px; + padding-left: 75px; float: left; } .custom-switch { display: block; - width: 90px; - height: 25px; + width: 58px; + height: 26px; position: relative; text-transform: uppercase; - border: 1px solid #999999; + border: none; + cursor: pointer; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; @@ -8452,14 +8693,14 @@ label { z-index: 4; display: block; position: absolute; - right: 50%; - top: 0; - width: 50%; - height: 100%; + right: 34px; + top: 2px; + width: 22px; + height: 22px; background-color: #f6f6f6; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; + -webkit-border-radius: 20px; + -moz-border-radius: 20px; + border-radius: 20px; -webkit-transition: all 0.1s; transition: all 0.1s; } @@ -8481,16 +8722,18 @@ label { filter: alpha(opacity=0); } .custom-switch input:checked ~ .slide-button { - right: 0%; + right: 2px; } .custom-switch input:checked ~ span { background-color: #8da85e; } .custom-switch input:checked ~ span span:first-of-type { color: #FFFFFF; + display: block; } .custom-switch input:checked ~ span span:last-of-type { color: #666666; + display: none; } .custom-switch > span { display: block; @@ -8499,28 +8742,34 @@ label { left: 0; width: 100%; background-color: #cc3300; + font-size: 11px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; + -webkit-border-radius: 20px; + -moz-border-radius: 20px; + border-radius: 20px; } .custom-switch > span span { z-index: 5; display: block; width: 50%; position: absolute; - top: 0; + top: 1px; left: 0; - text-align: center; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .custom-switch > span span:last-child { left: 50%; color: #FFFFFF; + display: block; } .custom-switch > span span:first-of-type { + padding-left: 9px; + display: none; color: #666666; } .custom-select .select2-choice { @@ -10185,7 +10434,7 @@ html.cssanimations .cursor-loading-indicator.hide { font-size: 13px; border: none; text-align: left; - outline: none!important; + outline: none !important; } .btn[class^="oc-icon-"]:before, .btn[class*=" oc-icon-"]:before { @@ -10856,12 +11105,14 @@ body.dropdown-open .dropdown-overlay { .control-tabs.primary > div > ul.nav-tabs, .control-tabs.primary > div > div > ul.nav-tabs { position: relative; + margin-left: -20px; + margin-right: -20px; } .control-tabs.primary > ul.nav-tabs:before, .control-tabs.primary > div > ul.nav-tabs:before, .control-tabs.primary > div > div > ul.nav-tabs:before { position: absolute; - top: 19px; + top: 26px; height: 1px; width: 100%; content: ' '; @@ -10873,16 +11124,64 @@ body.dropdown-open .dropdown-overlay { padding-right: 10px; padding-left: 11px; margin-right: 0; + margin-left: -30px; background: transparent; } +.control-tabs.primary > ul.nav-tabs > li:first-child, +.control-tabs.primary > div > ul.nav-tabs > li:first-child, +.control-tabs.primary > div > div > ul.nav-tabs > li:first-child { + margin-left: 0; + padding-left: 15px!important; +} .control-tabs.primary > ul.nav-tabs > li a, .control-tabs.primary > div > ul.nav-tabs > li a, .control-tabs.primary > div > div > ul.nav-tabs > li a { font-size: 12px; padding-bottom: 3px; + padding: 0 16px; + margin: 0; position: relative; z-index: 101; background: transparent; + overflow: visible; +} +.control-tabs.primary > ul.nav-tabs > li a > span.title, +.control-tabs.primary > div > ul.nav-tabs > li a > span.title, +.control-tabs.primary > div > div > ul.nav-tabs > li a > span.title { + position: relative; + display: inline-block; + padding: 5px 5px 9px 5px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border-top: 1px solid #f0f0f0; + z-index: 100; +} +.control-tabs.primary > ul.nav-tabs > li a > span.title:before, +.control-tabs.primary > div > ul.nav-tabs > li a > span.title:before, +.control-tabs.primary > div > div > ul.nav-tabs > li a > span.title:before, +.control-tabs.primary > ul.nav-tabs > li a > span.title:after, +.control-tabs.primary > div > ul.nav-tabs > li a > span.title:after, +.control-tabs.primary > div > div > ul.nav-tabs > li a > span.title:after { + content: ' '; + position: absolute; + background: transparent url(../images/primary-tab-shape.png) no-repeat left -31px; + width: 16px; + height: 26px; + display: block; + top: -1px; + z-index: 100; +} +.control-tabs.primary > ul.nav-tabs > li a > span.title:before, +.control-tabs.primary > div > ul.nav-tabs > li a > span.title:before, +.control-tabs.primary > div > div > ul.nav-tabs > li a > span.title:before { + left: -16px; +} +.control-tabs.primary > ul.nav-tabs > li a > span.title:after, +.control-tabs.primary > div > ul.nav-tabs > li a > span.title:after, +.control-tabs.primary > div > div > ul.nav-tabs > li a > span.title:after { + right: -16px; + background-position: -61px -31px; } .control-tabs.primary > ul.nav-tabs > li:last-child, .control-tabs.primary > div > ul.nav-tabs > li:last-child, @@ -10899,12 +11198,36 @@ body.dropdown-open .dropdown-overlay { .control-tabs.primary > ul.nav-tabs > li.active a:before, .control-tabs.primary > div > ul.nav-tabs > li.active a:before, .control-tabs.primary > div > div > ul.nav-tabs > li.active a:before { - content: ' '; position: absolute; - width: 100%; + top: 26px; + height: 1px; + right: 2px; left: 0; - top: 19px; - border-bottom: 1px solid #ec8017; + content: ' '; + background-color: #fafafa; +} +.control-tabs.primary > ul.nav-tabs > li.active a, +.control-tabs.primary > div > ul.nav-tabs > li.active a, +.control-tabs.primary > div > div > ul.nav-tabs > li.active a { + z-index: 107; +} +.control-tabs.primary > ul.nav-tabs > li.active a > span.title, +.control-tabs.primary > div > ul.nav-tabs > li.active a > span.title, +.control-tabs.primary > div > div > ul.nav-tabs > li.active a > span.title { + z-index: 105; + border-top-color: #d6d6d6; +} +.control-tabs.primary > ul.nav-tabs > li.active a > span.title:before, +.control-tabs.primary > div > ul.nav-tabs > li.active a > span.title:before, +.control-tabs.primary > div > div > ul.nav-tabs > li.active a > span.title:before { + background-position: left 0; + z-index: 107; +} +.control-tabs.primary > ul.nav-tabs > li.active a > span.title:after, +.control-tabs.primary > div > ul.nav-tabs > li.active a > span.title:after, +.control-tabs.primary > div > div > ul.nav-tabs > li.active a > span.title:after { + background-position: -61px 0; + z-index: 107; } .control-tabs.secondary > ul.nav-tabs > li, .control-tabs.secondary > div > ul.nav-tabs > li, @@ -12862,3 +13185,112 @@ div[data-control="balloon-selector"]:not(.control-disabled) ul li:hover { .callout.no-subheader > .header i { margin-top: -5px; } +.sidenav-tree { + width: 280px; + background: #34495e; +} +.sidenav-tree .control-toolbar { + padding: 20px 0 20px 20px; +} +.sidenav-tree .control-toolbar input.form-control { + border: none; +} +.sidenav-tree ul { + padding: 0; + margin: 0; + list-style: none; +} +.sidenav-tree div.scrollbar-thumb { + background: #2b3e50!important; +} +.sidenav-tree ul.top-level > li[data-status=collapsed] > div.group h3:before { + -webkit-transform: rotate(0deg) translate(3px, 0); + -ms-transform: rotate(0deg) translate(3px, 0); + transform: rotate(0deg) translate(3px, 0); +} +.sidenav-tree ul.top-level > li[data-status=collapsed] ul { + display: none; +} +.sidenav-tree ul.top-level > li > div.group h3 { + background: #2b3e50; + color: #ecf0f1; + text-transform: uppercase; + font-size: 14px; + padding: 15px 15px 15px 33px; + margin: 0; + position: relative; + cursor: pointer; +} +.sidenav-tree ul.top-level > li > div.group h3:before { + width: 10px; + height: 10px; + display: block; + position: absolute; + top: 1px; +} +.sidenav-tree ul.top-level > li > div.group h3:before { + left: 13px; + top: 15px; + color: #cfcfcf; + font-family: FontAwesome; + font-weight: normal; + font-style: normal; + text-decoration: inherit; + -webkit-font-smoothing: antialiased; + *margin-right: .3em; + content: "\f0da"; + -webkit-transform: rotate(90deg) translate(5px, 0); + -ms-transform: rotate(90deg) translate(5px, 0); + transform: rotate(90deg) translate(5px, 0); + -webkit-transition: all 0.1s ease; + transition: all 0.1s ease; +} +.sidenav-tree ul.top-level > li > ul li a { + display: block; + position: relative; + padding: 15px 15px 15px 40px; + color: #808b93; + background: #3d5265; + margin-bottom: 1px; + text-decoration: none!important; +} +.sidenav-tree ul.top-level > li > ul li a:hover { + text-decoration: none; +} +.sidenav-tree ul.top-level > li > ul li a i { + position: absolute; + left: 15px; + top: 17px; + font-size: 16px; +} +.sidenav-tree ul.top-level > li > ul li a span { + display: block; + line-height: 150%; +} +.sidenav-tree ul.top-level > li > ul li a span.header { + font-size: 14px; + margin-bottom: 5px; +} +.sidenav-tree ul.top-level > li > ul li a span.description { + font-size: 12px; + font-weight: 100; +} +.sidenav-tree ul.top-level > li > ul li.active a { + background: #34495e; + color: #ecf0f1; +} +.sidenav-tree ul.top-level > li > ul li.active a:before { + content: ' '; + position: absolute; + width: 4px; + background: #e6802b; + left: 0; + top: 0; + height: 100%; +} +.sidenav-tree ul.top-level > li > ul li:last-child a { + margin-bottom: 0; +} +.sidenav-tree ul.top-level > li > ul li:hover a { + background-color: #34495e; +} diff --git a/modules/backend/assets/images/primary-tab-shape.png b/modules/backend/assets/images/primary-tab-shape.png new file mode 100644 index 000000000..8cec7349e Binary files /dev/null and b/modules/backend/assets/images/primary-tab-shape.png differ diff --git a/modules/backend/assets/js/october.scrollbar.js b/modules/backend/assets/js/october.scrollbar.js index 8b620bb13..c4c47f9c6 100644 --- a/modules/backend/assets/js/october.scrollbar.js +++ b/modules/backend/assets/js/october.scrollbar.js @@ -255,6 +255,57 @@ : this.$el.get(0).scrollWidth; } + Scrollbar.prototype.gotoElement = function(element, callback) { + var $el = $(element) + if (!$el.length) + return; + + var self = this, + offset = 0, + animated = false, + params = { + duration: 300, + queue: false, + complete: function(){ + if (callback !== undefined) + callback() + } + } + + if (!this.options.vertical) { + offset = $el.get(0).offsetLeft - this.$el.scrollLeft() + + if (offset < 0) { + this.$el.animate({'scrollLeft': $el.get(0).offsetLeft}, params) + animated = true + } else { + offset = $el.get(0).offsetLeft + $el.outerWidth() - (this.$el.scrollLeft() + this.$el.outerWidth()) + if (offset > 0) { + this.$el.animate({'scrollLeft': $el.get(0).offsetLeft + $el.outerWidth() - this.$el.outerWidth()}, params) + animated = true + } + } + } else { + offset = $el.get(0).offsetTop - this.$el.scrollTop() + + if (offset < 0) { + this.$el.animate({'scrollTop': $el.get(0).offsetTop}, params) + animated = true + } else { + offset = $el.get(0).offsetTop - (this.$el.scrollTop() + this.$el.outerHeight()) + if (offset > 0) { + this.$el.animate({'scrollTop': $el.get(0).offsetTop + $el.outerHeight() - this.$el.outerHeight()}, params) + animated = true + } + } + } + + if (!animated && callback !== undefined) + callback() + + return this + } + // SCROLLBAR PLUGIN DEFINITION // ============================ diff --git a/modules/backend/assets/js/october.sidenav-tree.js b/modules/backend/assets/js/october.sidenav-tree.js new file mode 100644 index 000000000..cb4e20db8 --- /dev/null +++ b/modules/backend/assets/js/october.sidenav-tree.js @@ -0,0 +1,254 @@ +/* + * Side navigation tree + * + * Data attributes: + * - data-control="sidenav-tree" - enables the plugin + * - data-tree-name - unique name of the tree control. The name is used for storing user configuration in the browser cookies. + * + * JavaScript API: + * $('#tree').sidenavTree() + * + * Dependences: + * - Null + */ + ++function ($) { "use strict"; + + // SIDENAVTREE CLASS DEFINITION + // ============================ + + var SidenavTree = function(element, options) { + this.options = options + this.$el = $(element) + + this.init(); + } + + SidenavTree.DEFAULTS = { + treeName: 'sidenav_tree' + } + + SidenavTree.prototype.init = function (){ + var self = this + + this.statusCookieName = this.options.treeName + 'groupStatus' + this.searchCookieName = this.options.treeName + 'search' + this.$searchInput = $(this.options.searchInput) + + this.$el.on('click', 'li > div.group', function() { + self.toggleGroup($(this).closest('li')) + + return false; + }); + + this.$searchInput.on('keyup', function(){ + self.handleSearchChange() + }) + + var searchTerm = $.cookie(this.searchCookieName) + if (searchTerm !== undefined && searchTerm.length > 0) { + this.$searchInput.val(searchTerm) + this.applySearch() + } + + var scrollbar = $('[data-control=scrollbar]', this.$el).data('oc.scrollbar'), + active = $('li.active', this.$el) + + if (active.length > 0) + scrollbar.gotoElement(active) + } + + SidenavTree.prototype.toggleGroup = function(group) { + var $group = $(group), + status = $group.attr('data-status') + + status === undefined || status == 'expanded' ? + this.collapseGroup($group) : + this.expandGroup($group) + } + + SidenavTree.prototype.collapseGroup = function(group) { + var + $list = $('> ul', group), + self = this; + + $list.css('overflow', 'hidden') + $list.animate({'height': 0}, { duration: 100, queue: false, complete: function() { + $list.css({ + 'overflow': 'visible', + 'display': 'none' + }) + $(group).attr('data-status', 'collapsed') + $(window).trigger('oc.updateUi') + self.saveGroupStatus($(group).data('group-code'), true) + } }) + } + + SidenavTree.prototype.expandGroup = function(group, duration) { + var + $list = $('> ul', group), + self = this + + duration = duration === undefined ? 100 : duration + + $list.css({ + 'overflow': 'hidden', + 'display': 'block', + 'height': 0 + }) + $list.animate({'height': $list[0].scrollHeight}, { duration: duration, queue: false, complete: function() { + $list.css({ + 'overflow': 'visible', + 'height': 'auto' + }) + $(group).attr('data-status', 'expanded') + $(window).trigger('oc.updateUi') + self.saveGroupStatus($(group).data('group-code'), false) + } }) + } + + SidenavTree.prototype.saveGroupStatus = function(groupCode, collapsed) { + var collapsedGroups = $.cookie(this.statusCookieName), + updatedGroups = [] + + if (collapsedGroups === undefined) + collapsedGroups = '' + + collapsedGroups = collapsedGroups.split('|') + $.each(collapsedGroups, function() { + if (groupCode != this) + updatedGroups.push(this) + }) + + if (collapsed) + updatedGroups.push(groupCode) + + $.cookie(this.statusCookieName, updatedGroups.join('|'), { expires: 30, path: '/' }) + } + + SidenavTree.prototype.handleSearchChange = function() { + var lastValue = this.$searchInput.data('oc.lastvalue'); + + if (lastValue !== undefined && lastValue == this.$searchInput.val()) + return + + this.$searchInput.data('oc.lastvalue', this.$searchInput.val()) + + if (this.dataTrackInputTimer !== undefined) + window.clearTimeout(this.dataTrackInputTimer); + + var self = this + this.dataTrackInputTimer = window.setTimeout(function(){ + self.applySearch() + }, 300); + + $.cookie(this.searchCookieName, $.trim(this.$searchInput.val()), { expires: 30, path: '/' }) + } + + SidenavTree.prototype.applySearch = function() { + var query = $.trim(this.$searchInput.val()), + words = query.toLowerCase().split(' '), + visibleGroups = [], + visibleItems = [], + self = this + + if (query.length == 0) { + $('li', this.$el).removeClass('hidden') + + return + } + + // Find visible groups and items + // + $('ul.top-level > li', this.$el).each(function() { + var $li = $(this) + + if (self.textContainsWords($('div.group h3', $li).text(), words)) { + visibleGroups.push($li.get(0)) + + $('ul li', $li).each(function(){ + visibleItems.push(this) + }) + } else { + $('ul li', $li).each(function(){ + if (self.textContainsWords($(this).text(), words) || self.textContainsWords($(this).data('keywords'), words)) { + visibleGroups.push($li.get(0)) + visibleItems.push(this) + } + }) + } + }) + + // Hide invisible groups and items + // + $('ul.top-level > li', this.$el).each(function() { + var $li = $(this), + groupIsVisible = $.inArray(this, visibleGroups) !== -1 + + $li.toggleClass('hidden', !groupIsVisible) + if (groupIsVisible) + self.expandGroup($li, 0) + + $('ul li', $li).each(function(){ + var $itemLi = $(this) + + $itemLi.toggleClass('hidden', $.inArray(this, visibleItems) == -1) + }) + }) + + return false + } + + SidenavTree.prototype.textContainsWords = function(text, words) { + text = text.toLowerCase() + + for (var i = 0; i < words.length; i++) { + if (text.indexOf(words[i]) === -1) + return false + } + + return true + } + + // SIDENAVTREE PLUGIN DEFINITION + // ============================ + + var old = $.fn.sidenavTree + + $.fn.sidenavTree = function (option) { + var args = arguments; + + return this.each(function () { + var $this = $(this) + var data = $this.data('oc.sidenavTree') + var options = $.extend({}, SidenavTree.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('oc.sidenavTree', (data = new SidenavTree(this, options))) + if (typeof option == 'string') { + var methodArgs = []; + for (var i=1; i 1 && !$.isFunction(value)) { + options = $.extend({}, config.defaults, options); + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setTime(+t + days * 864e+5); + } + + return (document.cookie = [ + encode(key), '=', stringifyCookieValue(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // Read + + var result = key ? undefined : {}; + + // To prevent the for loop in the first place assign an empty array + // in case there are no cookies at all. Also prevents odd result when + // calling $.cookie(). + var cookies = document.cookie ? document.cookie.split('; ') : []; + + for (var i = 0, l = cookies.length; i < l; i++) { + var parts = cookies[i].split('='); + var name = decode(parts.shift()); + var cookie = parts.join('='); + + if (key && key === name) { + // If second argument (value) is a function it's a converter... + result = read(cookie, value); + break; + } + + // Prevent storing a cookie that we couldn't decode. + if (!key && (cookie = read(cookie)) !== undefined) { + result[name] = cookie; + } + } + + return result; + }; + + config.defaults = {}; + + $.removeCookie = function (key, options) { + if ($.cookie(key) === undefined) { + return false; + } + + // Must not alter options, thus extending a fresh object... + $.cookie(key, '', $.extend({}, options, { expires: -1 })); + return !$.cookie(key); + }; + +})); diff --git a/modules/backend/assets/less/controls/button.less b/modules/backend/assets/less/controls/button.less index c9c3028dd..0366cba93 100644 --- a/modules/backend/assets/less/controls/button.less +++ b/modules/backend/assets/less/controls/button.less @@ -6,7 +6,7 @@ font-size: 13px; border: none; text-align: left; - outline: none!important; + outline: none !important; &[class^="oc-icon-"], &[class*=" oc-icon-"] { diff --git a/modules/backend/assets/less/controls/forms.less b/modules/backend/assets/less/controls/forms.less index 4afe2ac04..618e26d18 100644 --- a/modules/backend/assets/less/controls/forms.less +++ b/modules/backend/assets/less/controls/forms.less @@ -13,6 +13,7 @@ label { .form-control { .transition(none); .box-shadow(none); + .border-radius(3px); &:focus { .box-shadow(none); } @@ -209,11 +210,10 @@ label { .btn { background: transparent; position: absolute; - right: 0; + right: -2px; top: 50%; margin-top: -44px; height: 88px; - width: 36px; color: lighten(@btn-default-color, 15%); i { @@ -361,18 +361,19 @@ label { .switch-field { .field-switch { - padding-left: 105px; + padding-left: 75px; float: left; } } .custom-switch { display: block; - width: 90px; - height: 25px; + width: 58px; + height: 26px; position: relative; text-transform: uppercase; - border: 1px solid @color-custom-input-border; + border: none; + cursor: pointer; .border-radius(3px); * { .box-sizing(border-box); } @@ -381,12 +382,12 @@ label { z-index: 4; display: block; position: absolute; - right: 50%; - top: 0; - width: 50%; - height: 100%; + right: 34px; + top: 2px; + width: 22px; + height: 22px; background-color: @color-switch-input-bg; - .border-radius(3px); + .border-radius(20px); .transition(all 0.1s); } @@ -408,11 +409,19 @@ label { position: absolute; .opacity(0); &:checked { - ~ .slide-button { right: 0%; } + ~ .slide-button { + right: 2px; + } ~ span { background-color: @color-switch-input-on; } ~ span span { - &:first-of-type { color: #FFFFFF; } - &:last-of-type { color: #666666; } + &:first-of-type { + color: #FFFFFF; + display: block; + } + &:last-of-type { + color: #666666; + display: none; + } } } } @@ -424,19 +433,28 @@ label { left: 0; width: 100%; background-color: @color-switch-input-off; + font-size: 11px; .user-select(none); - .border-radius(3px); + .border-radius(20px); span { z-index: 5; display: block; width: 50%; position: absolute; - top: 0; + top: 1px; left: 0; - text-align: center; - &:last-child { left: 50%; color: #FFFFFF; } - &:first-of-type { color: #666666; } + .box-sizing(border-box); + &:last-child { + left: 50%; + color: #FFFFFF; + display: block; + } + &:first-of-type { + padding-left: 9px; + display: none; + color: #666666; + } } } } diff --git a/modules/backend/assets/less/controls/sidenav-tree.less b/modules/backend/assets/less/controls/sidenav-tree.less new file mode 100644 index 000000000..72eb5b3df --- /dev/null +++ b/modules/backend/assets/less/controls/sidenav-tree.less @@ -0,0 +1,127 @@ +.sidenav-tree { + width: 280px; + background: @color-sidebarnav-bg; + + .control-toolbar { + padding: 20px 0 20px 20px; + + input.form-control { + border: none; + } + } + + ul { + padding: 0; + margin: 0; + list-style: none; + } + + div.scrollbar-thumb { + background: #2b3e50!important; + } + + ul.top-level > li { + &[data-status=collapsed] { + > div.group h3:before { + .transform( ~'rotate(0deg) translate(3px, 0)' ); + } + + ul { + display: none; + } + } + + > div.group { + h3 { + background: @color-sidebarnav-tree-group-bg; + color: @color-sidebarnav-tree-group; + text-transform: uppercase; + font-size: 14px; + padding: 15px 15px 15px 33px; + margin: 0; + position: relative; + cursor: pointer; + + &:before { + width: 10px; + height: 10px; + display: block; + position: absolute; + top: 1px; + } + + &:before { + left: 13px; + top: 15px; + color: @color-list-arrow; + .icon(@caret-right); + .transform( ~'rotate(90deg) translate(5px, 0)' ); + .transition(all 0.1s ease); + } + } + } + + > ul { + li { + a { + display: block; + position: relative; + padding: 15px 15px 15px 40px; + color: @color-sidebarnav-tree-inactive-text; + background: @color-sidebarnav-tree-inactive-bg; + margin-bottom: 1px; + text-decoration: none!important; + + &:hover { + text-decoration: none; + } + + i { + position: absolute; + left: 15px; + top: 17px; + font-size: 16px; + } + + span { + display: block; + line-height: 150%; + + &.header { + font-size: 14px; + margin-bottom: 5px; + } + + &.description { + font-size: 12px; + font-weight: 100; + } + } + } + + &.active a { + background: @color-sidebarnav-tree-active-bg; + color: @color-sidebarnav-tree-active-text; + + &:before { + content: ' '; + position: absolute; + width: 4px; + background: @color-sidebarnav-tree-active-marker; + left: 0; + top: 0; + height: 100%; + } + } + + &:last-child a { + margin-bottom: 0; + } + + &:hover a { + background-color: @color-sidebarnav-tree-active-bg; + } + } + } + } +} \ No newline at end of file diff --git a/modules/backend/assets/less/controls/tab.less b/modules/backend/assets/less/controls/tab.less index 5dee7990f..679fe12bf 100644 --- a/modules/backend/assets/less/controls/tab.less +++ b/modules/backend/assets/less/controls/tab.less @@ -171,10 +171,12 @@ > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs { position: relative; + margin-left: -20px; + margin-right: -20px; &:before { position: absolute; - top: 19px; + top: 26px; height: 1px; width: 100%; content: ' '; @@ -185,14 +187,52 @@ padding-right: 10px; padding-left: 11px; margin-right: 0; + margin-left: -30px; background: transparent; + + &:first-child { + margin-left: 0; + padding-left: 15px!important; + } a { font-size: 12px; padding-bottom: 3px; + padding: 0 16px; + margin: 0; position: relative; z-index: 101; background: transparent; + overflow: visible; + + > span.title { + position: relative; + display: inline-block; + padding: 5px 5px 9px 5px; + .box-sizing(border-box); + border-top: 1px solid #f0f0f0; + z-index: 100; + + &:before, &:after { + content: ' '; + position: absolute; + background: transparent url(../images/primary-tab-shape.png) no-repeat left -31px; + width: 16px; + height: 26px; + display: block; + top: -1px; + z-index: 100; + } + + &:before { + left: -16px; + } + + &:after { + right: -16px; + background-position: -61px -31px; + } + } } &:last-child { @@ -205,14 +245,32 @@ padding-left: 0; } - &.active a { - &:before { - content: ' '; - position: absolute; - width: 100%; - left: 0; - top: 19px; - border-bottom: 1px solid @color-tab-active-marker; + &.active a:before { + position: absolute; + top: 26px; + height: 1px; + right: 2px; + left: 0; + content: ' '; + background-color: @color-body-bg; + } + + &.active a{ + z-index: 107; + + > span.title { + z-index: 105; + border-top-color: #d6d6d6; + + &:before { + background-position: left 0; + z-index: 107; + } + + &:after { + background-position: -61px 0; + z-index: 107; + } } } } diff --git a/modules/backend/assets/less/core/icons.less b/modules/backend/assets/less/core/icons.less index 9946816bf..66e970a21 100644 --- a/modules/backend/assets/less/core/icons.less +++ b/modules/backend/assets/less/core/icons.less @@ -71,6 +71,8 @@ .oc-icon-outdent:before { content: @outdent; } .oc-icon-indent:before { content: @indent; } .oc-icon-video-camera:before { content: @video-camera; } +.oc-icon-photo:before, +.oc-icon-image:before, .oc-icon-picture-o:before { content: @picture-o; } .oc-icon-pencil:before { content: @pencil; } .oc-icon-map-marker:before { content: @map-marker; } @@ -198,6 +200,8 @@ .oc-icon-save:before, .oc-icon-floppy-o:before { content: @floppy-o; } .oc-icon-square:before { content: @square; } +.oc-icon-navicon:before, +.oc-icon-reorder:before, .oc-icon-bars:before { content: @bars; } .oc-icon-list-ul:before { content: @list-ul; } .oc-icon-list-ol:before { content: @list-ol; } @@ -219,9 +223,9 @@ .oc-icon-unsorted:before, .oc-icon-sort:before { content: @sort; } .oc-icon-sort-down:before, -.oc-icon-sort-asc:before { content: @sort-asc; } -.oc-icon-sort-up:before, .oc-icon-sort-desc:before { content: @sort-desc; } +.oc-icon-sort-up:before, +.oc-icon-sort-asc:before { content: @sort-asc; } .oc-icon-envelope:before { content: @envelope; } .oc-icon-linkedin:before { content: @linkedin; } .oc-icon-rotate-left:before, @@ -289,8 +293,8 @@ .oc-icon-flag-checkered:before { content: @flag-checkered; } .oc-icon-terminal:before { content: @terminal; } .oc-icon-code:before { content: @code; } +.oc-icon-mail-reply-all:before, .oc-icon-reply-all:before { content: @reply-all; } -.oc-icon-mail-reply-all:before { content: @mail-reply-all; } .oc-icon-star-half-empty:before, .oc-icon-star-half-full:before, .oc-icon-star-half-o:before { content: @star-half-o; } @@ -418,3 +422,93 @@ .oc-icon-turkish-lira:before, .oc-icon-try:before { content: @try; } .oc-icon-plus-square-o:before { content: @plus-square-o; } +.oc-icon-space-shuttle:before { content: @space-shuttle; } +.oc-icon-slack:before { content: @slack; } +.oc-icon-envelope-square:before { content: @envelope-square; } +.oc-icon-wordpress:before { content: @wordpress; } +.oc-icon-openid:before { content: @openid; } +.oc-icon-institution:before, +.oc-icon-bank:before, +.oc-icon-university:before { content: @university; } +.oc-icon-mortar-board:before, +.oc-icon-graduation-cap:before { content: @graduation-cap; } +.oc-icon-yahoo:before { content: @yahoo; } +.oc-icon-google:before { content: @google; } +.oc-icon-reddit:before { content: @reddit; } +.oc-icon-reddit-square:before { content: @reddit-square; } +.oc-icon-stumbleupon-circle:before { content: @stumbleupon-circle; } +.oc-icon-stumbleupon:before { content: @stumbleupon; } +.oc-icon-delicious:before { content: @delicious; } +.oc-icon-digg:before { content: @digg; } +.oc-icon-pied-piper-square:before, +.oc-icon-pied-piper:before { content: @pied-piper; } +.oc-icon-pied-piper-alt:before { content: @pied-piper-alt; } +.oc-icon-drupal:before { content: @drupal; } +.oc-icon-joomla:before { content: @joomla; } +.oc-icon-language:before { content: @language; } +.oc-icon-fax:before { content: @fax; } +.oc-icon-building:before { content: @building; } +.oc-icon-child:before { content: @child; } +.oc-icon-paw:before { content: @paw; } +.oc-icon-spoon:before { content: @spoon; } +.oc-icon-cube:before { content: @cube; } +.oc-icon-cubes:before { content: @cubes; } +.oc-icon-behance:before { content: @behance; } +.oc-icon-behance-square:before { content: @behance-square; } +.oc-icon-steam:before { content: @steam; } +.oc-icon-steam-square:before { content: @steam-square; } +.oc-icon-recycle:before { content: @recycle; } +.oc-icon-automobile:before, +.oc-icon-car:before { content: @car; } +.oc-icon-cab:before, +.oc-icon-taxi:before { content: @taxi; } +.oc-icon-tree:before { content: @tree; } +.oc-icon-spotify:before { content: @spotify; } +.oc-icon-deviantart:before { content: @deviantart; } +.oc-icon-soundcloud:before { content: @soundcloud; } +.oc-icon-database:before { content: @database; } +.oc-icon-file-pdf-o:before { content: @file-pdf-o; } +.oc-icon-file-word-o:before { content: @file-word-o; } +.oc-icon-file-excel-o:before { content: @file-excel-o; } +.oc-icon-file-powerpoint-o:before { content: @file-powerpoint-o; } +.oc-icon-file-photo-o:before, +.oc-icon-file-picture-o:before, +.oc-icon-file-image-o:before { content: @file-image-o; } +.oc-icon-file-zip-o:before, +.oc-icon-file-archive-o:before { content: @file-archive-o; } +.oc-icon-file-sound-o:before, +.oc-icon-file-audio-o:before { content: @file-audio-o; } +.oc-icon-file-movie-o:before, +.oc-icon-file-video-o:before { content: @file-video-o; } +.oc-icon-file-code-o:before { content: @file-code-o; } +.oc-icon-vine:before { content: @vine; } +.oc-icon-codepen:before { content: @codepen; } +.oc-icon-jsfiddle:before { content: @jsfiddle; } +.oc-icon-life-bouy:before, +.oc-icon-life-saver:before, +.oc-icon-support:before, +.oc-icon-life-ring:before { content: @life-ring; } +.oc-icon-circle-o-notch:before { content: @circle-o-notch; } +.oc-icon-ra:before, +.oc-icon-rebel:before { content: @rebel; } +.oc-icon-ge:before, +.oc-icon-empire:before { content: @empire; } +.oc-icon-git-square:before { content: @git-square; } +.oc-icon-git:before { content: @git; } +.oc-icon-hacker-news:before { content: @hacker-news; } +.oc-icon-tencent-weibo:before { content: @tencent-weibo; } +.oc-icon-qq:before { content: @qq; } +.oc-icon-wechat:before, +.oc-icon-weixin:before { content: @weixin; } +.oc-icon-send:before, +.oc-icon-paper-plane:before { content: @paper-plane; } +.oc-icon-send-o:before, +.oc-icon-paper-plane-o:before { content: @paper-plane-o; } +.oc-icon-history:before { content: @history; } +.oc-icon-circle-thin:before { content: @circle-thin; } +.oc-icon-header:before { content: @header; } +.oc-icon-paragraph:before { content: @paragraph; } +.oc-icon-sliders:before { content: @sliders; } +.oc-icon-share-alt:before { content: @share-alt; } +.oc-icon-share-alt-square:before { content: @share-alt-square; } +.oc-icon-bomb:before { content: @bomb; } diff --git a/modules/backend/assets/less/core/mixins.less b/modules/backend/assets/less/core/mixins.less index c28549113..4058c6b67 100644 --- a/modules/backend/assets/less/core/mixins.less +++ b/modules/backend/assets/less/core/mixins.less @@ -1,3 +1,13 @@ +// +// Override Bootstrap mixins +// -------------------------------------------------- + +.button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) { + padding: @padding-vertical (@padding-horizontal * 1.5); + font-size: @font-size; + line-height: @line-height; + border-radius: @border-radius; +} // Triangles // -------------------------------------------------- diff --git a/modules/backend/assets/less/core/variables.less b/modules/backend/assets/less/core/variables.less index 9479fd5ad..ed8ee8011 100644 --- a/modules/backend/assets/less/core/variables.less +++ b/modules/backend/assets/less/core/variables.less @@ -76,6 +76,14 @@ @color-sidebarnav-counter-bg: #d9350f; @color-sidebarnav-counter-text: #ffffff; +@color-sidebarnav-tree-group: #ecf0f1; +@color-sidebarnav-tree-group-bg: #2b3e50; +@color-sidebarnav-tree-inactive-text: #808b93; +@color-sidebarnav-tree-inactive-bg: #3d5265; +@color-sidebarnav-tree-active-bg: #34495e; +@color-sidebarnav-tree-active-text: #ecf0f1; +@color-sidebarnav-tree-active-marker: #e6802b; + @color-list-active: #dddddd; @color-list-hover: #dddddd; @color-list-active-border: #e67e22; diff --git a/modules/backend/assets/less/october.less b/modules/backend/assets/less/october.less index 2b7f57420..364de5238 100644 --- a/modules/backend/assets/less/october.less +++ b/modules/backend/assets/less/october.less @@ -42,3 +42,4 @@ @import "controls/reportwidgets.less"; @import "controls/treelist.less"; @import "controls/callout.less"; +@import "controls/sidenav-tree.less"; diff --git a/modules/backend/classes/NavigationManager.php b/modules/backend/classes/NavigationManager.php index fcd04cef7..e1a275bfa 100644 --- a/modules/backend/classes/NavigationManager.php +++ b/modules/backend/classes/NavigationManager.php @@ -24,6 +24,8 @@ class NavigationManager */ private $items; + private $contextSidenavPartials = []; + private $contextOwner; private $contextMainMenuItemCode; private $contextSideMenuItemCode; @@ -295,9 +297,9 @@ class NavigationManager /** * Sets the navigation context. * The function sets the navigation owner, main menu item code and the side menu item code. - * @param string @owner Specifies the navigation owner in the format Vendor/Module - * @param string @mainMenuItemCode Specifies the main menu item code - * @param string @sideMenuItemCode Specifies the side menu item code + * @param string $owner Specifies the navigation owner in the format Vendor/Module + * @param string $mainMenuItemCode Specifies the main menu item code + * @param string $sideMenuItemCode Specifies the side menu item code */ public function setContext($owner, $mainMenuItemCode, $sideMenuItemCode = null) { @@ -309,7 +311,7 @@ class NavigationManager /** * Sets the navigation context. * The function sets the navigation owner. - * @param string @owner Specifies the navigation owner in the format Vendor/Module + * @param string $owner Specifies the navigation owner in the format Vendor/Module */ public function setContextOwner($owner) { @@ -318,7 +320,7 @@ class NavigationManager /** * Specifies a code of the main menu item in the current navigation context. - * @param string @mainMenuItemCode Specifies the main menu item code + * @param string $mainMenuItemCode Specifies the main menu item code */ public function setContextMainMenu($mainMenuItemCode) { @@ -330,18 +332,20 @@ class NavigationManager * @return mixed Returns an object with the following fields: * - mainMenuCode * - sideMenuCode + * - owner */ public function getContext() { return (object)[ 'mainMenuCode' => $this->contextMainMenuItemCode, - 'sideMenuCode' => $this->contextSideMenuItemCode + 'sideMenuCode' => $this->contextSideMenuItemCode, + 'owner' => $this->contextOwner ]; } /** * Specifies a code of the side menu item in the current navigation context. - * @param string @sideMenuItemCode Specifies the side menu item code + * @param string $sideMenuItemCode Specifies the side menu item code */ public function setContextSideMenu($sideMenuItemCode) { @@ -350,7 +354,7 @@ class NavigationManager /** * Determines if a main menu item is active. - * @param mixed @item Specifies the item object. + * @param mixed $item Specifies the item object. * @return boolean Returns true if the menu item is active. */ public function isMainMenuItemActive($item) @@ -360,7 +364,7 @@ class NavigationManager /** * Determines if a side menu item is active. - * @param mixed @item Specifies the item object. + * @param mixed $item Specifies the item object. * @return boolean Returns true if the side item is active. */ public function isSideMenuItemActive($item) @@ -368,6 +372,33 @@ class NavigationManager return $this->contextOwner == $item->owner && $this->contextSideMenuItemCode == $item->code; } + /** + * Registers a special side navigation partial for a specific main menu. + * The sidenav partial replaces the standard side navigation. + * @param string $owner Specifies the navigation owner in the format Vendor/Module. + * @param string $mainMenuItemCode Specifies the main menu item code. + * @param string $partial Specifies the partial name. + */ + public function registerContextSidenavPartial($owner, $mainMenuItemCode, $partial) + { + $this->contextSidenavPartials[$owner.$mainMenuItemCode] = $partial; + } + + /** + * Returns the side navigation partial for a specific main menu previously registered with the registerContextSidenavPartial() method. + * @param string $owner Specifies the navigation owner in the format Vendor/Module. + * @param string $mainMenuItemCode Specifies the main menu item code. + * @return mixed Returns the partial name or null. + */ + public function getContextSidenavPartial($owner, $mainMenuItemCode) + { + $key = $owner.$mainMenuItemCode; + + return array_key_exists($key, $this->contextSidenavPartials) ? + $this->contextSidenavPartials[$key] : + null; + } + /** * Removes menu items from an array if the supplied user lacks permission. * @param User $user A user object diff --git a/modules/backend/controllers/EditorPreferences.php b/modules/backend/controllers/EditorPreferences.php index 51937200c..bc37ec44a 100644 --- a/modules/backend/controllers/EditorPreferences.php +++ b/modules/backend/controllers/EditorPreferences.php @@ -3,6 +3,7 @@ use Lang; use BackendMenu; use Backend\Classes\Controller; +use System\Classes\SettingsManager; use Backend\Models\EditorPreferences as EditorPreferencesModel; /** @@ -34,6 +35,7 @@ class EditorPreferences extends Controller $this->addJs('/modules/backend/assets/js/editorpreferences/editorpreferences.js', 'core'); BackendMenu::setContext('October.System', 'system', 'mysettings'); + SettingsManager::setContext('October.Backend', 'editor'); } public function index() diff --git a/modules/backend/controllers/Users.php b/modules/backend/controllers/Users.php index 6d8247f65..36a067a53 100644 --- a/modules/backend/controllers/Users.php +++ b/modules/backend/controllers/Users.php @@ -6,6 +6,7 @@ use Redirect; use BackendMenu; use BackendAuth; use Backend\Classes\Controller; +use System\Classes\SettingsManager; /** * Backend user controller @@ -36,6 +37,7 @@ class Users extends Controller $this->requiredPermissions = null; BackendMenu::setContext('October.System', 'system', 'users'); + SettingsManager::setContext('October.System', 'administrators'); } /** @@ -55,7 +57,8 @@ class Users extends Controller */ public function myaccount() { - BackendMenu::setContextSideMenu('mysettings'); + SettingsManager::setContext('October.Backend', 'myaccount'); + $this->pageTitle = Lang::get('backend::lang.myaccount.menu_label'); return $this->update($this->user->id, 'myaccount'); } diff --git a/modules/backend/controllers/editorpreferences/index.htm b/modules/backend/controllers/editorpreferences/index.htm index a66351741..26ec34f6e 100644 --- a/modules/backend/controllers/editorpreferences/index.htm +++ b/modules/backend/controllers/editorpreferences/index.htm @@ -1,10 +1,3 @@ - - - - fatalError): ?> 'layout-item stretch layout-column']) ?> diff --git a/modules/backend/controllers/users/myaccount.htm b/modules/backend/controllers/users/myaccount.htm index e046fa852..d9f646246 100644 --- a/modules/backend/controllers/users/myaccount.htm +++ b/modules/backend/controllers/users/myaccount.htm @@ -1,10 +1,3 @@ - - - - fatalError): ?> diff --git a/modules/backend/formwidgets/Datepicker.php b/modules/backend/formwidgets/Datepicker.php index fb204d403..730dfc384 100644 --- a/modules/backend/formwidgets/Datepicker.php +++ b/modules/backend/formwidgets/Datepicker.php @@ -79,6 +79,7 @@ class Datepicker extends FormWidgetBase { $this->addCss('vendor/pikaday/css/pikaday.css', 'core'); $this->addCss('css/datepicker.css', 'core'); + $this->addJs('vendor/moment/moment.js', 'core'); $this->addJs('vendor/pikaday/js/pikaday.js', 'core'); $this->addJs('vendor/pikaday/js/pikaday.jquery.js', 'core'); $this->addJs('js/datepicker.js', 'core'); diff --git a/modules/backend/formwidgets/datepicker/assets/js/datepicker.js b/modules/backend/formwidgets/datepicker/assets/js/datepicker.js index 4214944ef..acbdf3777 100644 --- a/modules/backend/formwidgets/datepicker/assets/js/datepicker.js +++ b/modules/backend/formwidgets/datepicker/assets/js/datepicker.js @@ -40,7 +40,7 @@ minDate: new Date(options.minDate), maxDate: new Date(options.maxDate), yearRange: options.yearRange, - defaultDate: new Date(), + setDefaultDate: moment(this.$input.val()).toDate(), onOpen: function() { var $field = $(this._o.trigger) diff --git a/modules/backend/formwidgets/datepicker/assets/vendor/moment/README.md b/modules/backend/formwidgets/datepicker/assets/vendor/moment/README.md new file mode 100644 index 000000000..0ab228178 --- /dev/null +++ b/modules/backend/formwidgets/datepicker/assets/vendor/moment/README.md @@ -0,0 +1,39 @@ +[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url] + +A lightweight javascript date library for parsing, validating, manipulating, and formatting dates. + +## [Documentation](http://momentjs.com/docs/) + +## Upgrading to 2.0.0 + +There are a number of small backwards incompatible changes with version 2.0.0. [See the full descriptions here](https://gist.github.com/timrwood/e72f2eef320ed9e37c51#backwards-incompatible-changes) + + * Changed language ordinal method to return the number + ordinal instead of just the ordinal. + + * Changed two digit year parsing cutoff to match strptime. + + * Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`. + + * Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`. + + * Removed the lang data objects from the top level namespace. + + * Duplicate `Date` passed to `moment()` instead of referencing it. + +## [Changelog](CHANGELOG.md) + +## [Contributing](CONTRIBUTING.md) + +## License + +Moment.js is freely distributable under the terms of the [MIT license](LICENSE). + +[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat +[license-url]: LICENSE + +[npm-url]: https://npmjs.org/package/moment +[npm-version-image]: http://img.shields.io/npm/v/moment.svg?style=flat +[npm-downloads-image]: http://img.shields.io/npm/dm/moment.svg?style=flat + +[travis-url]: http://travis-ci.org/moment/moment +[travis-image]: http://img.shields.io/travis/moment/moment/develop.svg?style=flat \ No newline at end of file diff --git a/modules/backend/formwidgets/datepicker/assets/vendor/moment/moment.js b/modules/backend/formwidgets/datepicker/assets/vendor/moment/moment.js new file mode 100644 index 000000000..80adc8e97 --- /dev/null +++ b/modules/backend/formwidgets/datepicker/assets/vendor/moment/moment.js @@ -0,0 +1,2610 @@ +//! moment.js +//! version : 2.7.0 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com + +(function (undefined) { + + /************************************ + Constants + ************************************/ + + var moment, + VERSION = "2.7.0", + // the global-scope this is NOT the global object in Node.js + globalScope = typeof global !== 'undefined' ? global : this, + oldGlobalMoment, + round = Math.round, + i, + + YEAR = 0, + MONTH = 1, + DATE = 2, + HOUR = 3, + MINUTE = 4, + SECOND = 5, + MILLISECOND = 6, + + // internal storage for language config files + languages = {}, + + // moment internal properties + momentProperties = { + _isAMomentObject: null, + _i : null, + _f : null, + _l : null, + _strict : null, + _tzm : null, + _isUTC : null, + _offset : null, // optional. Combine with _isUTC + _pf : null, + _lang : null // optional + }, + + // check for nodeJS + hasModule = (typeof module !== 'undefined' && module.exports), + + // ASP.NET json date format regex + aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, + aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/, + + // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html + // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere + isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/, + + // format tokens + formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g, + localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g, + + // parsing token regexes + parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 + parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 + parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999 + parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999 + parseTokenDigits = /\d+/, // nonzero number of digits + parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic. + parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z + parseTokenT = /T/i, // T (ISO separator) + parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 + parseTokenOrdinal = /\d{1,2}/, + + //strict parsing regexes + parseTokenOneDigit = /\d/, // 0 - 9 + parseTokenTwoDigits = /\d\d/, // 00 - 99 + parseTokenThreeDigits = /\d{3}/, // 000 - 999 + parseTokenFourDigits = /\d{4}/, // 0000 - 9999 + parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999 + parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf + + // iso 8601 regex + // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) + isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/, + + isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', + + isoDates = [ + ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/], + ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/], + ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/], + ['GGGG-[W]WW', /\d{4}-W\d{2}/], + ['YYYY-DDD', /\d{4}-\d{3}/] + ], + + // iso time formats and regexes + isoTimes = [ + ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/], + ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], + ['HH:mm', /(T| )\d\d:\d\d/], + ['HH', /(T| )\d\d/] + ], + + // timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"] + parseTimezoneChunker = /([\+\-]|\d\d)/gi, + + // getter and setter names + proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'), + unitMillisecondFactors = { + 'Milliseconds' : 1, + 'Seconds' : 1e3, + 'Minutes' : 6e4, + 'Hours' : 36e5, + 'Days' : 864e5, + 'Months' : 2592e6, + 'Years' : 31536e6 + }, + + unitAliases = { + ms : 'millisecond', + s : 'second', + m : 'minute', + h : 'hour', + d : 'day', + D : 'date', + w : 'week', + W : 'isoWeek', + M : 'month', + Q : 'quarter', + y : 'year', + DDD : 'dayOfYear', + e : 'weekday', + E : 'isoWeekday', + gg: 'weekYear', + GG: 'isoWeekYear' + }, + + camelFunctions = { + dayofyear : 'dayOfYear', + isoweekday : 'isoWeekday', + isoweek : 'isoWeek', + weekyear : 'weekYear', + isoweekyear : 'isoWeekYear' + }, + + // format function strings + formatFunctions = {}, + + // default relative time thresholds + relativeTimeThresholds = { + s: 45, //seconds to minutes + m: 45, //minutes to hours + h: 22, //hours to days + dd: 25, //days to month (month == 1) + dm: 45, //days to months (months > 1) + dy: 345 //days to year + }, + + // tokens to ordinalize and pad + ordinalizeTokens = 'DDD w W M D d'.split(' '), + paddedTokens = 'M D H h m s w W'.split(' '), + + formatTokenFunctions = { + M : function () { + return this.month() + 1; + }, + MMM : function (format) { + return this.lang().monthsShort(this, format); + }, + MMMM : function (format) { + return this.lang().months(this, format); + }, + D : function () { + return this.date(); + }, + DDD : function () { + return this.dayOfYear(); + }, + d : function () { + return this.day(); + }, + dd : function (format) { + return this.lang().weekdaysMin(this, format); + }, + ddd : function (format) { + return this.lang().weekdaysShort(this, format); + }, + dddd : function (format) { + return this.lang().weekdays(this, format); + }, + w : function () { + return this.week(); + }, + W : function () { + return this.isoWeek(); + }, + YY : function () { + return leftZeroFill(this.year() % 100, 2); + }, + YYYY : function () { + return leftZeroFill(this.year(), 4); + }, + YYYYY : function () { + return leftZeroFill(this.year(), 5); + }, + YYYYYY : function () { + var y = this.year(), sign = y >= 0 ? '+' : '-'; + return sign + leftZeroFill(Math.abs(y), 6); + }, + gg : function () { + return leftZeroFill(this.weekYear() % 100, 2); + }, + gggg : function () { + return leftZeroFill(this.weekYear(), 4); + }, + ggggg : function () { + return leftZeroFill(this.weekYear(), 5); + }, + GG : function () { + return leftZeroFill(this.isoWeekYear() % 100, 2); + }, + GGGG : function () { + return leftZeroFill(this.isoWeekYear(), 4); + }, + GGGGG : function () { + return leftZeroFill(this.isoWeekYear(), 5); + }, + e : function () { + return this.weekday(); + }, + E : function () { + return this.isoWeekday(); + }, + a : function () { + return this.lang().meridiem(this.hours(), this.minutes(), true); + }, + A : function () { + return this.lang().meridiem(this.hours(), this.minutes(), false); + }, + H : function () { + return this.hours(); + }, + h : function () { + return this.hours() % 12 || 12; + }, + m : function () { + return this.minutes(); + }, + s : function () { + return this.seconds(); + }, + S : function () { + return toInt(this.milliseconds() / 100); + }, + SS : function () { + return leftZeroFill(toInt(this.milliseconds() / 10), 2); + }, + SSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + SSSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + Z : function () { + var a = -this.zone(), + b = "+"; + if (a < 0) { + a = -a; + b = "-"; + } + return b + leftZeroFill(toInt(a / 60), 2) + ":" + leftZeroFill(toInt(a) % 60, 2); + }, + ZZ : function () { + var a = -this.zone(), + b = "+"; + if (a < 0) { + a = -a; + b = "-"; + } + return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2); + }, + z : function () { + return this.zoneAbbr(); + }, + zz : function () { + return this.zoneName(); + }, + X : function () { + return this.unix(); + }, + Q : function () { + return this.quarter(); + } + }, + + lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error("Implement me"); + } + } + + function defaultParsingFlags() { + // We need to deep clone this object, and es5 standard is not very + // helpful. + return { + empty : false, + unusedTokens : [], + unusedInput : [], + overflow : -2, + charsLeftOver : 0, + nullInput : false, + invalidMonth : null, + invalidFormat : false, + userInvalidated : false, + iso: false + }; + } + + function deprecate(msg, fn) { + var firstTime = true; + function printMsg() { + if (moment.suppressDeprecationWarnings === false && + typeof console !== 'undefined' && console.warn) { + console.warn("Deprecation warning: " + msg); + } + } + return extend(function () { + if (firstTime) { + printMsg(); + firstTime = false; + } + return fn.apply(this, arguments); + }, fn); + } + + function padToken(func, count) { + return function (a) { + return leftZeroFill(func.call(this, a), count); + }; + } + function ordinalizeToken(func, period) { + return function (a) { + return this.lang().ordinal(func.call(this, a), period); + }; + } + + while (ordinalizeTokens.length) { + i = ordinalizeTokens.pop(); + formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i); + } + while (paddedTokens.length) { + i = paddedTokens.pop(); + formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2); + } + formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3); + + + /************************************ + Constructors + ************************************/ + + function Language() { + + } + + // Moment prototype object + function Moment(config) { + checkOverflow(config); + extend(this, config); + } + + // Duration Constructor + function Duration(duration) { + var normalizedInput = normalizeObjectUnits(duration), + years = normalizedInput.year || 0, + quarters = normalizedInput.quarter || 0, + months = normalizedInput.month || 0, + weeks = normalizedInput.week || 0, + days = normalizedInput.day || 0, + hours = normalizedInput.hour || 0, + minutes = normalizedInput.minute || 0, + seconds = normalizedInput.second || 0, + milliseconds = normalizedInput.millisecond || 0; + + // representation for dateAddRemove + this._milliseconds = +milliseconds + + seconds * 1e3 + // 1000 + minutes * 6e4 + // 1000 * 60 + hours * 36e5; // 1000 * 60 * 60 + // Because of dateAddRemove treats 24 hours as different from a + // day when working around DST, we need to store them separately + this._days = +days + + weeks * 7; + // It is impossible translate months into days without knowing + // which months you are are talking about, so we have to store + // it separately. + this._months = +months + + quarters * 3 + + years * 12; + + this._data = {}; + + this._bubble(); + } + + /************************************ + Helpers + ************************************/ + + + function extend(a, b) { + for (var i in b) { + if (b.hasOwnProperty(i)) { + a[i] = b[i]; + } + } + + if (b.hasOwnProperty("toString")) { + a.toString = b.toString; + } + + if (b.hasOwnProperty("valueOf")) { + a.valueOf = b.valueOf; + } + + return a; + } + + function cloneMoment(m) { + var result = {}, i; + for (i in m) { + if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) { + result[i] = m[i]; + } + } + + return result; + } + + function absRound(number) { + if (number < 0) { + return Math.ceil(number); + } else { + return Math.floor(number); + } + } + + // left zero fill a number + // see http://jsperf.com/left-zero-filling for performance comparison + function leftZeroFill(number, targetLength, forceSign) { + var output = '' + Math.abs(number), + sign = number >= 0; + + while (output.length < targetLength) { + output = '0' + output; + } + return (sign ? (forceSign ? '+' : '') : '-') + output; + } + + // helper function for _.addTime and _.subtractTime + function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) { + var milliseconds = duration._milliseconds, + days = duration._days, + months = duration._months; + updateOffset = updateOffset == null ? true : updateOffset; + + if (milliseconds) { + mom._d.setTime(+mom._d + milliseconds * isAdding); + } + if (days) { + rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding); + } + if (months) { + rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding); + } + if (updateOffset) { + moment.updateOffset(mom, days || months); + } + } + + // check if is an array + function isArray(input) { + return Object.prototype.toString.call(input) === '[object Array]'; + } + + function isDate(input) { + return Object.prototype.toString.call(input) === '[object Date]' || + input instanceof Date; + } + + // compare two arrays, return the number of differences + function compareArrays(array1, array2, dontConvert) { + var len = Math.min(array1.length, array2.length), + lengthDiff = Math.abs(array1.length - array2.length), + diffs = 0, + i; + for (i = 0; i < len; i++) { + if ((dontConvert && array1[i] !== array2[i]) || + (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { + diffs++; + } + } + return diffs + lengthDiff; + } + + function normalizeUnits(units) { + if (units) { + var lowered = units.toLowerCase().replace(/(.)s$/, '$1'); + units = unitAliases[units] || camelFunctions[lowered] || lowered; + } + return units; + } + + function normalizeObjectUnits(inputObject) { + var normalizedInput = {}, + normalizedProp, + prop; + + for (prop in inputObject) { + if (inputObject.hasOwnProperty(prop)) { + normalizedProp = normalizeUnits(prop); + if (normalizedProp) { + normalizedInput[normalizedProp] = inputObject[prop]; + } + } + } + + return normalizedInput; + } + + function makeList(field) { + var count, setter; + + if (field.indexOf('week') === 0) { + count = 7; + setter = 'day'; + } + else if (field.indexOf('month') === 0) { + count = 12; + setter = 'month'; + } + else { + return; + } + + moment[field] = function (format, index) { + var i, getter, + method = moment.fn._lang[field], + results = []; + + if (typeof format === 'number') { + index = format; + format = undefined; + } + + getter = function (i) { + var m = moment().utc().set(setter, i); + return method.call(moment.fn._lang, m, format || ''); + }; + + if (index != null) { + return getter(index); + } + else { + for (i = 0; i < count; i++) { + results.push(getter(i)); + } + return results; + } + }; + } + + function toInt(argumentForCoercion) { + var coercedNumber = +argumentForCoercion, + value = 0; + + if (coercedNumber !== 0 && isFinite(coercedNumber)) { + if (coercedNumber >= 0) { + value = Math.floor(coercedNumber); + } else { + value = Math.ceil(coercedNumber); + } + } + + return value; + } + + function daysInMonth(year, month) { + return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); + } + + function weeksInYear(year, dow, doy) { + return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week; + } + + function daysInYear(year) { + return isLeapYear(year) ? 366 : 365; + } + + function isLeapYear(year) { + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + } + + function checkOverflow(m) { + var overflow; + if (m._a && m._pf.overflow === -2) { + overflow = + m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH : + m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE : + m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR : + m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE : + m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND : + m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND : + -1; + + if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { + overflow = DATE; + } + + m._pf.overflow = overflow; + } + } + + function isValid(m) { + if (m._isValid == null) { + m._isValid = !isNaN(m._d.getTime()) && + m._pf.overflow < 0 && + !m._pf.empty && + !m._pf.invalidMonth && + !m._pf.nullInput && + !m._pf.invalidFormat && + !m._pf.userInvalidated; + + if (m._strict) { + m._isValid = m._isValid && + m._pf.charsLeftOver === 0 && + m._pf.unusedTokens.length === 0; + } + } + return m._isValid; + } + + function normalizeLanguage(key) { + return key ? key.toLowerCase().replace('_', '-') : key; + } + + // Return a moment from input, that is local/utc/zone equivalent to model. + function makeAs(input, model) { + return model._isUTC ? moment(input).zone(model._offset || 0) : + moment(input).local(); + } + + /************************************ + Languages + ************************************/ + + + extend(Language.prototype, { + + set : function (config) { + var prop, i; + for (i in config) { + prop = config[i]; + if (typeof prop === 'function') { + this[i] = prop; + } else { + this['_' + i] = prop; + } + } + }, + + _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), + months : function (m) { + return this._months[m.month()]; + }, + + _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"), + monthsShort : function (m) { + return this._monthsShort[m.month()]; + }, + + monthsParse : function (monthName) { + var i, mom, regex; + + if (!this._monthsParse) { + this._monthsParse = []; + } + + for (i = 0; i < 12; i++) { + // make the regex if we don't have it already + if (!this._monthsParse[i]) { + mom = moment.utc([2000, i]); + regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._monthsParse[i].test(monthName)) { + return i; + } + } + }, + + _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), + weekdays : function (m) { + return this._weekdays[m.day()]; + }, + + _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), + weekdaysShort : function (m) { + return this._weekdaysShort[m.day()]; + }, + + _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), + weekdaysMin : function (m) { + return this._weekdaysMin[m.day()]; + }, + + weekdaysParse : function (weekdayName) { + var i, mom, regex; + + if (!this._weekdaysParse) { + this._weekdaysParse = []; + } + + for (i = 0; i < 7; i++) { + // make the regex if we don't have it already + if (!this._weekdaysParse[i]) { + mom = moment([2000, 1]).day(i); + regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); + this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._weekdaysParse[i].test(weekdayName)) { + return i; + } + } + }, + + _longDateFormat : { + LT : "h:mm A", + L : "MM/DD/YYYY", + LL : "MMMM D YYYY", + LLL : "MMMM D YYYY LT", + LLLL : "dddd, MMMM D YYYY LT" + }, + longDateFormat : function (key) { + var output = this._longDateFormat[key]; + if (!output && this._longDateFormat[key.toUpperCase()]) { + output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { + return val.slice(1); + }); + this._longDateFormat[key] = output; + } + return output; + }, + + isPM : function (input) { + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays + // Using charAt should be more compatible. + return ((input + '').toLowerCase().charAt(0) === 'p'); + }, + + _meridiemParse : /[ap]\.?m?\.?/i, + meridiem : function (hours, minutes, isLower) { + if (hours > 11) { + return isLower ? 'pm' : 'PM'; + } else { + return isLower ? 'am' : 'AM'; + } + }, + + _calendar : { + sameDay : '[Today at] LT', + nextDay : '[Tomorrow at] LT', + nextWeek : 'dddd [at] LT', + lastDay : '[Yesterday at] LT', + lastWeek : '[Last] dddd [at] LT', + sameElse : 'L' + }, + calendar : function (key, mom) { + var output = this._calendar[key]; + return typeof output === 'function' ? output.apply(mom) : output; + }, + + _relativeTime : { + future : "in %s", + past : "%s ago", + s : "a few seconds", + m : "a minute", + mm : "%d minutes", + h : "an hour", + hh : "%d hours", + d : "a day", + dd : "%d days", + M : "a month", + MM : "%d months", + y : "a year", + yy : "%d years" + }, + relativeTime : function (number, withoutSuffix, string, isFuture) { + var output = this._relativeTime[string]; + return (typeof output === 'function') ? + output(number, withoutSuffix, string, isFuture) : + output.replace(/%d/i, number); + }, + pastFuture : function (diff, output) { + var format = this._relativeTime[diff > 0 ? 'future' : 'past']; + return typeof format === 'function' ? format(output) : format.replace(/%s/i, output); + }, + + ordinal : function (number) { + return this._ordinal.replace("%d", number); + }, + _ordinal : "%d", + + preparse : function (string) { + return string; + }, + + postformat : function (string) { + return string; + }, + + week : function (mom) { + return weekOfYear(mom, this._week.dow, this._week.doy).week; + }, + + _week : { + dow : 0, // Sunday is the first day of the week. + doy : 6 // The week that contains Jan 1st is the first week of the year. + }, + + _invalidDate: 'Invalid date', + invalidDate: function () { + return this._invalidDate; + } + }); + + // Loads a language definition into the `languages` cache. The function + // takes a key and optionally values. If not in the browser and no values + // are provided, it will load the language file module. As a convenience, + // this function also returns the language values. + function loadLang(key, values) { + values.abbr = key; + if (!languages[key]) { + languages[key] = new Language(); + } + languages[key].set(values); + return languages[key]; + } + + // Remove a language from the `languages` cache. Mostly useful in tests. + function unloadLang(key) { + delete languages[key]; + } + + // Determines which language definition to use and returns it. + // + // With no parameters, it will return the global language. If you + // pass in a language key, such as 'en', it will return the + // definition for 'en', so long as 'en' has already been loaded using + // moment.lang. + function getLangDefinition(key) { + var i = 0, j, lang, next, split, + get = function (k) { + if (!languages[k] && hasModule) { + try { + require('./lang/' + k); + } catch (e) { } + } + return languages[k]; + }; + + if (!key) { + return moment.fn._lang; + } + + if (!isArray(key)) { + //short-circuit everything else + lang = get(key); + if (lang) { + return lang; + } + key = [key]; + } + + //pick the language from the array + //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each + //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root + while (i < key.length) { + split = normalizeLanguage(key[i]).split('-'); + j = split.length; + next = normalizeLanguage(key[i + 1]); + next = next ? next.split('-') : null; + while (j > 0) { + lang = get(split.slice(0, j).join('-')); + if (lang) { + return lang; + } + if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { + //the next array item is better than a shallower substring of this one + break; + } + j--; + } + i++; + } + return moment.fn._lang; + } + + /************************************ + Formatting + ************************************/ + + + function removeFormattingTokens(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|\]$/g, ""); + } + return input.replace(/\\/g, ""); + } + + function makeFormatFunction(format) { + var array = format.match(formattingTokens), i, length; + + for (i = 0, length = array.length; i < length; i++) { + if (formatTokenFunctions[array[i]]) { + array[i] = formatTokenFunctions[array[i]]; + } else { + array[i] = removeFormattingTokens(array[i]); + } + } + + return function (mom) { + var output = ""; + for (i = 0; i < length; i++) { + output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; + } + return output; + }; + } + + // format date using native date object + function formatMoment(m, format) { + + if (!m.isValid()) { + return m.lang().invalidDate(); + } + + format = expandFormat(format, m.lang()); + + if (!formatFunctions[format]) { + formatFunctions[format] = makeFormatFunction(format); + } + + return formatFunctions[format](m); + } + + function expandFormat(format, lang) { + var i = 5; + + function replaceLongDateFormatTokens(input) { + return lang.longDateFormat(input) || input; + } + + localFormattingTokens.lastIndex = 0; + while (i >= 0 && localFormattingTokens.test(format)) { + format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); + localFormattingTokens.lastIndex = 0; + i -= 1; + } + + return format; + } + + + /************************************ + Parsing + ************************************/ + + + // get the regex to find the next token + function getParseRegexForToken(token, config) { + var a, strict = config._strict; + switch (token) { + case 'Q': + return parseTokenOneDigit; + case 'DDDD': + return parseTokenThreeDigits; + case 'YYYY': + case 'GGGG': + case 'gggg': + return strict ? parseTokenFourDigits : parseTokenOneToFourDigits; + case 'Y': + case 'G': + case 'g': + return parseTokenSignedNumber; + case 'YYYYYY': + case 'YYYYY': + case 'GGGGG': + case 'ggggg': + return strict ? parseTokenSixDigits : parseTokenOneToSixDigits; + case 'S': + if (strict) { return parseTokenOneDigit; } + /* falls through */ + case 'SS': + if (strict) { return parseTokenTwoDigits; } + /* falls through */ + case 'SSS': + if (strict) { return parseTokenThreeDigits; } + /* falls through */ + case 'DDD': + return parseTokenOneToThreeDigits; + case 'MMM': + case 'MMMM': + case 'dd': + case 'ddd': + case 'dddd': + return parseTokenWord; + case 'a': + case 'A': + return getLangDefinition(config._l)._meridiemParse; + case 'X': + return parseTokenTimestampMs; + case 'Z': + case 'ZZ': + return parseTokenTimezone; + case 'T': + return parseTokenT; + case 'SSSS': + return parseTokenDigits; + case 'MM': + case 'DD': + case 'YY': + case 'GG': + case 'gg': + case 'HH': + case 'hh': + case 'mm': + case 'ss': + case 'ww': + case 'WW': + return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits; + case 'M': + case 'D': + case 'd': + case 'H': + case 'h': + case 'm': + case 's': + case 'w': + case 'W': + case 'e': + case 'E': + return parseTokenOneOrTwoDigits; + case 'Do': + return parseTokenOrdinal; + default : + a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i")); + return a; + } + } + + function timezoneMinutesFromString(string) { + string = string || ""; + var possibleTzMatches = (string.match(parseTokenTimezone) || []), + tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [], + parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0], + minutes = +(parts[1] * 60) + toInt(parts[2]); + + return parts[0] === '+' ? -minutes : minutes; + } + + // function to convert string input to date + function addTimeToArrayFromToken(token, input, config) { + var a, datePartArray = config._a; + + switch (token) { + // QUARTER + case 'Q': + if (input != null) { + datePartArray[MONTH] = (toInt(input) - 1) * 3; + } + break; + // MONTH + case 'M' : // fall through to MM + case 'MM' : + if (input != null) { + datePartArray[MONTH] = toInt(input) - 1; + } + break; + case 'MMM' : // fall through to MMMM + case 'MMMM' : + a = getLangDefinition(config._l).monthsParse(input); + // if we didn't find a month name, mark the date as invalid. + if (a != null) { + datePartArray[MONTH] = a; + } else { + config._pf.invalidMonth = input; + } + break; + // DAY OF MONTH + case 'D' : // fall through to DD + case 'DD' : + if (input != null) { + datePartArray[DATE] = toInt(input); + } + break; + case 'Do' : + if (input != null) { + datePartArray[DATE] = toInt(parseInt(input, 10)); + } + break; + // DAY OF YEAR + case 'DDD' : // fall through to DDDD + case 'DDDD' : + if (input != null) { + config._dayOfYear = toInt(input); + } + + break; + // YEAR + case 'YY' : + datePartArray[YEAR] = moment.parseTwoDigitYear(input); + break; + case 'YYYY' : + case 'YYYYY' : + case 'YYYYYY' : + datePartArray[YEAR] = toInt(input); + break; + // AM / PM + case 'a' : // fall through to A + case 'A' : + config._isPm = getLangDefinition(config._l).isPM(input); + break; + // 24 HOUR + case 'H' : // fall through to hh + case 'HH' : // fall through to hh + case 'h' : // fall through to hh + case 'hh' : + datePartArray[HOUR] = toInt(input); + break; + // MINUTE + case 'm' : // fall through to mm + case 'mm' : + datePartArray[MINUTE] = toInt(input); + break; + // SECOND + case 's' : // fall through to ss + case 'ss' : + datePartArray[SECOND] = toInt(input); + break; + // MILLISECOND + case 'S' : + case 'SS' : + case 'SSS' : + case 'SSSS' : + datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000); + break; + // UNIX TIMESTAMP WITH MS + case 'X': + config._d = new Date(parseFloat(input) * 1000); + break; + // TIMEZONE + case 'Z' : // fall through to ZZ + case 'ZZ' : + config._useUTC = true; + config._tzm = timezoneMinutesFromString(input); + break; + // WEEKDAY - human + case 'dd': + case 'ddd': + case 'dddd': + a = getLangDefinition(config._l).weekdaysParse(input); + // if we didn't get a weekday name, mark the date as invalid + if (a != null) { + config._w = config._w || {}; + config._w['d'] = a; + } else { + config._pf.invalidWeekday = input; + } + break; + // WEEK, WEEK DAY - numeric + case 'w': + case 'ww': + case 'W': + case 'WW': + case 'd': + case 'e': + case 'E': + token = token.substr(0, 1); + /* falls through */ + case 'gggg': + case 'GGGG': + case 'GGGGG': + token = token.substr(0, 2); + if (input) { + config._w = config._w || {}; + config._w[token] = toInt(input); + } + break; + case 'gg': + case 'GG': + config._w = config._w || {}; + config._w[token] = moment.parseTwoDigitYear(input); + } + } + + function dayOfYearFromWeekInfo(config) { + var w, weekYear, week, weekday, dow, doy, temp, lang; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + dow = 1; + doy = 4; + + // TODO: We need to take the current isoWeekYear, but that depends on + // how we interpret now (local, utc, fixed offset). So create + // a now version of current config (take local/utc/offset flags, and + // create now). + weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year); + week = dfl(w.W, 1); + weekday = dfl(w.E, 1); + } else { + lang = getLangDefinition(config._l); + dow = lang._week.dow; + doy = lang._week.doy; + + weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year); + week = dfl(w.w, 1); + + if (w.d != null) { + // weekday -- low day numbers are considered next week + weekday = w.d; + if (weekday < dow) { + ++week; + } + } else if (w.e != null) { + // local weekday -- counting starts from begining of week + weekday = w.e + dow; + } else { + // default to begining of week + weekday = dow; + } + } + temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow); + + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + + // convert an array to a date. + // the array should mirror the parameters below + // note: all values past the year are optional and will default to the lowest possible value. + // [year, month, day , hour, minute, second, millisecond] + function dateFromConfig(config) { + var i, date, input = [], currentDate, yearToUse; + + if (config._d) { + return; + } + + currentDate = currentDateArray(config); + + //compute day of the year from weeks and weekdays + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { + dayOfYearFromWeekInfo(config); + } + + //if the day of the year is set, figure out what it is + if (config._dayOfYear) { + yearToUse = dfl(config._a[YEAR], currentDate[YEAR]); + + if (config._dayOfYear > daysInYear(yearToUse)) { + config._pf._overflowDayOfYear = true; + } + + date = makeUTCDate(yearToUse, 0, config._dayOfYear); + config._a[MONTH] = date.getUTCMonth(); + config._a[DATE] = date.getUTCDate(); + } + + // Default to current date. + // * if no year, month, day of month are given, default to today + // * if day of month is given, default month and year + // * if month is given, default only year + // * if year is given, don't default anything + for (i = 0; i < 3 && config._a[i] == null; ++i) { + config._a[i] = input[i] = currentDate[i]; + } + + // Zero out whatever was not defaulted, including time + for (; i < 7; i++) { + config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; + } + + config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + // Apply timezone offset from input. The actual zone can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); + } + } + + function dateFromObject(config) { + var normalizedInput; + + if (config._d) { + return; + } + + normalizedInput = normalizeObjectUnits(config._i); + config._a = [ + normalizedInput.year, + normalizedInput.month, + normalizedInput.day, + normalizedInput.hour, + normalizedInput.minute, + normalizedInput.second, + normalizedInput.millisecond + ]; + + dateFromConfig(config); + } + + function currentDateArray(config) { + var now = new Date(); + if (config._useUTC) { + return [ + now.getUTCFullYear(), + now.getUTCMonth(), + now.getUTCDate() + ]; + } else { + return [now.getFullYear(), now.getMonth(), now.getDate()]; + } + } + + // date from string and format string + function makeDateFromStringAndFormat(config) { + + if (config._f === moment.ISO_8601) { + parseISO(config); + return; + } + + config._a = []; + config._pf.empty = true; + + // This array is used to make a Date, either with `new Date` or `Date.UTC` + var lang = getLangDefinition(config._l), + string = '' + config._i, + i, parsedInput, tokens, token, skipped, + stringLength = string.length, + totalParsedInputLength = 0; + + tokens = expandFormat(config._f, lang).match(formattingTokens) || []; + + for (i = 0; i < tokens.length; i++) { + token = tokens[i]; + parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; + if (parsedInput) { + skipped = string.substr(0, string.indexOf(parsedInput)); + if (skipped.length > 0) { + config._pf.unusedInput.push(skipped); + } + string = string.slice(string.indexOf(parsedInput) + parsedInput.length); + totalParsedInputLength += parsedInput.length; + } + // don't parse if it's not a known token + if (formatTokenFunctions[token]) { + if (parsedInput) { + config._pf.empty = false; + } + else { + config._pf.unusedTokens.push(token); + } + addTimeToArrayFromToken(token, parsedInput, config); + } + else if (config._strict && !parsedInput) { + config._pf.unusedTokens.push(token); + } + } + + // add remaining unparsed input length to the string + config._pf.charsLeftOver = stringLength - totalParsedInputLength; + if (string.length > 0) { + config._pf.unusedInput.push(string); + } + + // handle am pm + if (config._isPm && config._a[HOUR] < 12) { + config._a[HOUR] += 12; + } + // if is 12 am, change hours to 0 + if (config._isPm === false && config._a[HOUR] === 12) { + config._a[HOUR] = 0; + } + + dateFromConfig(config); + checkOverflow(config); + } + + function unescapeFormat(s) { + return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { + return p1 || p2 || p3 || p4; + }); + } + + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript + function regexpEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + + // date from string and array of format strings + function makeDateFromStringAndArray(config) { + var tempConfig, + bestMoment, + + scoreToBeat, + i, + currentScore; + + if (config._f.length === 0) { + config._pf.invalidFormat = true; + config._d = new Date(NaN); + return; + } + + for (i = 0; i < config._f.length; i++) { + currentScore = 0; + tempConfig = extend({}, config); + tempConfig._pf = defaultParsingFlags(); + tempConfig._f = config._f[i]; + makeDateFromStringAndFormat(tempConfig); + + if (!isValid(tempConfig)) { + continue; + } + + // if there is any input that was not parsed add a penalty for that format + currentScore += tempConfig._pf.charsLeftOver; + + //or tokens + currentScore += tempConfig._pf.unusedTokens.length * 10; + + tempConfig._pf.score = currentScore; + + if (scoreToBeat == null || currentScore < scoreToBeat) { + scoreToBeat = currentScore; + bestMoment = tempConfig; + } + } + + extend(config, bestMoment || tempConfig); + } + + // date from iso format + function parseISO(config) { + var i, l, + string = config._i, + match = isoRegex.exec(string); + + if (match) { + config._pf.iso = true; + for (i = 0, l = isoDates.length; i < l; i++) { + if (isoDates[i][1].exec(string)) { + // match[5] should be "T" or undefined + config._f = isoDates[i][0] + (match[6] || " "); + break; + } + } + for (i = 0, l = isoTimes.length; i < l; i++) { + if (isoTimes[i][1].exec(string)) { + config._f += isoTimes[i][0]; + break; + } + } + if (string.match(parseTokenTimezone)) { + config._f += "Z"; + } + makeDateFromStringAndFormat(config); + } else { + config._isValid = false; + } + } + + // date from iso format or fallback + function makeDateFromString(config) { + parseISO(config); + if (config._isValid === false) { + delete config._isValid; + moment.createFromInputFallback(config); + } + } + + function makeDateFromInput(config) { + var input = config._i, + matched = aspNetJsonRegex.exec(input); + + if (input === undefined) { + config._d = new Date(); + } else if (matched) { + config._d = new Date(+matched[1]); + } else if (typeof input === 'string') { + makeDateFromString(config); + } else if (isArray(input)) { + config._a = input.slice(0); + dateFromConfig(config); + } else if (isDate(input)) { + config._d = new Date(+input); + } else if (typeof(input) === 'object') { + dateFromObject(config); + } else if (typeof(input) === 'number') { + // from milliseconds + config._d = new Date(input); + } else { + moment.createFromInputFallback(config); + } + } + + function makeDate(y, m, d, h, M, s, ms) { + //can't just apply() to create a date: + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply + var date = new Date(y, m, d, h, M, s, ms); + + //the date constructor doesn't accept years < 1970 + if (y < 1970) { + date.setFullYear(y); + } + return date; + } + + function makeUTCDate(y) { + var date = new Date(Date.UTC.apply(null, arguments)); + if (y < 1970) { + date.setUTCFullYear(y); + } + return date; + } + + function parseWeekday(input, language) { + if (typeof input === 'string') { + if (!isNaN(input)) { + input = parseInt(input, 10); + } + else { + input = language.weekdaysParse(input); + if (typeof input !== 'number') { + return null; + } + } + } + return input; + } + + /************************************ + Relative Time + ************************************/ + + + // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize + function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) { + return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture); + } + + function relativeTime(milliseconds, withoutSuffix, lang) { + var seconds = round(Math.abs(milliseconds) / 1000), + minutes = round(seconds / 60), + hours = round(minutes / 60), + days = round(hours / 24), + years = round(days / 365), + args = seconds < relativeTimeThresholds.s && ['s', seconds] || + minutes === 1 && ['m'] || + minutes < relativeTimeThresholds.m && ['mm', minutes] || + hours === 1 && ['h'] || + hours < relativeTimeThresholds.h && ['hh', hours] || + days === 1 && ['d'] || + days <= relativeTimeThresholds.dd && ['dd', days] || + days <= relativeTimeThresholds.dm && ['M'] || + days < relativeTimeThresholds.dy && ['MM', round(days / 30)] || + years === 1 && ['y'] || ['yy', years]; + args[2] = withoutSuffix; + args[3] = milliseconds > 0; + args[4] = lang; + return substituteTimeAgo.apply({}, args); + } + + + /************************************ + Week of Year + ************************************/ + + + // firstDayOfWeek 0 = sun, 6 = sat + // the day of the week that starts the week + // (usually sunday or monday) + // firstDayOfWeekOfYear 0 = sun, 6 = sat + // the first week is the week that contains the first + // of this day of the week + // (eg. ISO weeks use thursday (4)) + function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { + var end = firstDayOfWeekOfYear - firstDayOfWeek, + daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(), + adjustedMoment; + + + if (daysToDayOfWeek > end) { + daysToDayOfWeek -= 7; + } + + if (daysToDayOfWeek < end - 7) { + daysToDayOfWeek += 7; + } + + adjustedMoment = moment(mom).add('d', daysToDayOfWeek); + return { + week: Math.ceil(adjustedMoment.dayOfYear() / 7), + year: adjustedMoment.year() + }; + } + + //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday + function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { + var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; + + d = d === 0 ? 7 : d; + weekday = weekday != null ? weekday : firstDayOfWeek; + daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); + dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; + + return { + year: dayOfYear > 0 ? year : year - 1, + dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + }; + } + + /************************************ + Top Level Functions + ************************************/ + + function makeMoment(config) { + var input = config._i, + format = config._f; + + if (input === null || (format === undefined && input === '')) { + return moment.invalid({nullInput: true}); + } + + if (typeof input === 'string') { + config._i = input = getLangDefinition().preparse(input); + } + + if (moment.isMoment(input)) { + config = cloneMoment(input); + + config._d = new Date(+input._d); + } else if (format) { + if (isArray(format)) { + makeDateFromStringAndArray(config); + } else { + makeDateFromStringAndFormat(config); + } + } else { + makeDateFromInput(config); + } + + return new Moment(config); + } + + moment = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._i = input; + c._f = format; + c._l = lang; + c._strict = strict; + c._isUTC = false; + c._pf = defaultParsingFlags(); + + return makeMoment(c); + }; + + moment.suppressDeprecationWarnings = false; + + moment.createFromInputFallback = deprecate( + "moment construction falls back to js Date. This is " + + "discouraged and will be removed in upcoming major " + + "release. Please refer to " + + "https://github.com/moment/moment/issues/1407 for more info.", + function (config) { + config._d = new Date(config._i); + }); + + // Pick a moment m from moments so that m[fn](other) is true for all + // other. This relies on the function fn to be transitive. + // + // moments should either be an array of moment objects or an array, whose + // first element is an array of moment objects. + function pickBy(fn, moments) { + var res, i; + if (moments.length === 1 && isArray(moments[0])) { + moments = moments[0]; + } + if (!moments.length) { + return moment(); + } + res = moments[0]; + for (i = 1; i < moments.length; ++i) { + if (moments[i][fn](res)) { + res = moments[i]; + } + } + return res; + } + + moment.min = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isBefore', args); + }; + + moment.max = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isAfter', args); + }; + + // creating with utc + moment.utc = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._useUTC = true; + c._isUTC = true; + c._l = lang; + c._i = input; + c._f = format; + c._strict = strict; + c._pf = defaultParsingFlags(); + + return makeMoment(c).utc(); + }; + + // creating with unix timestamp (in seconds) + moment.unix = function (input) { + return moment(input * 1000); + }; + + // duration + moment.duration = function (input, key) { + var duration = input, + // matching against regexp is expensive, do it on demand + match = null, + sign, + ret, + parseIso; + + if (moment.isDuration(input)) { + duration = { + ms: input._milliseconds, + d: input._days, + M: input._months + }; + } else if (typeof input === 'number') { + duration = {}; + if (key) { + duration[key] = input; + } else { + duration.milliseconds = input; + } + } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; + duration = { + y: 0, + d: toInt(match[DATE]) * sign, + h: toInt(match[HOUR]) * sign, + m: toInt(match[MINUTE]) * sign, + s: toInt(match[SECOND]) * sign, + ms: toInt(match[MILLISECOND]) * sign + }; + } else if (!!(match = isoDurationRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; + parseIso = function (inp) { + // We'd normally use ~~inp for this, but unfortunately it also + // converts floats to ints. + // inp may be undefined, so careful calling replace on it. + var res = inp && parseFloat(inp.replace(',', '.')); + // apply sign while we're at it + return (isNaN(res) ? 0 : res) * sign; + }; + duration = { + y: parseIso(match[2]), + M: parseIso(match[3]), + d: parseIso(match[4]), + h: parseIso(match[5]), + m: parseIso(match[6]), + s: parseIso(match[7]), + w: parseIso(match[8]) + }; + } + + ret = new Duration(duration); + + if (moment.isDuration(input) && input.hasOwnProperty('_lang')) { + ret._lang = input._lang; + } + + return ret; + }; + + // version number + moment.version = VERSION; + + // default format + moment.defaultFormat = isoFormat; + + // constant that refers to the ISO standard + moment.ISO_8601 = function () {}; + + // Plugins that add properties should also add the key here (null value), + // so we can properly clone ourselves. + moment.momentProperties = momentProperties; + + // This function will be called whenever a moment is mutated. + // It is intended to keep the offset in sync with the timezone. + moment.updateOffset = function () {}; + + // This function allows you to set a threshold for relative time strings + moment.relativeTimeThreshold = function(threshold, limit) { + if (relativeTimeThresholds[threshold] === undefined) { + return false; + } + relativeTimeThresholds[threshold] = limit; + return true; + }; + + // This function will load languages and then set the global language. If + // no arguments are passed in, it will simply return the current global + // language key. + moment.lang = function (key, values) { + var r; + if (!key) { + return moment.fn._lang._abbr; + } + if (values) { + loadLang(normalizeLanguage(key), values); + } else if (values === null) { + unloadLang(key); + key = 'en'; + } else if (!languages[key]) { + getLangDefinition(key); + } + r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key); + return r._abbr; + }; + + // returns language data + moment.langData = function (key) { + if (key && key._lang && key._lang._abbr) { + key = key._lang._abbr; + } + return getLangDefinition(key); + }; + + // compare moment object + moment.isMoment = function (obj) { + return obj instanceof Moment || + (obj != null && obj.hasOwnProperty('_isAMomentObject')); + }; + + // for typechecking Duration objects + moment.isDuration = function (obj) { + return obj instanceof Duration; + }; + + for (i = lists.length - 1; i >= 0; --i) { + makeList(lists[i]); + } + + moment.normalizeUnits = function (units) { + return normalizeUnits(units); + }; + + moment.invalid = function (flags) { + var m = moment.utc(NaN); + if (flags != null) { + extend(m._pf, flags); + } + else { + m._pf.userInvalidated = true; + } + + return m; + }; + + moment.parseZone = function () { + return moment.apply(null, arguments).parseZone(); + }; + + moment.parseTwoDigitYear = function (input) { + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); + }; + + /************************************ + Moment Prototype + ************************************/ + + + extend(moment.fn = Moment.prototype, { + + clone : function () { + return moment(this); + }, + + valueOf : function () { + return +this._d + ((this._offset || 0) * 60000); + }, + + unix : function () { + return Math.floor(+this / 1000); + }, + + toString : function () { + return this.clone().lang('en').format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); + }, + + toDate : function () { + return this._offset ? new Date(+this) : this._d; + }, + + toISOString : function () { + var m = moment(this).utc(); + if (0 < m.year() && m.year() <= 9999) { + return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } else { + return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } + }, + + toArray : function () { + var m = this; + return [ + m.year(), + m.month(), + m.date(), + m.hours(), + m.minutes(), + m.seconds(), + m.milliseconds() + ]; + }, + + isValid : function () { + return isValid(this); + }, + + isDSTShifted : function () { + + if (this._a) { + return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0; + } + + return false; + }, + + parsingFlags : function () { + return extend({}, this._pf); + }, + + invalidAt: function () { + return this._pf.overflow; + }, + + utc : function () { + return this.zone(0); + }, + + local : function () { + this.zone(0); + this._isUTC = false; + return this; + }, + + format : function (inputString) { + var output = formatMoment(this, inputString || moment.defaultFormat); + return this.lang().postformat(output); + }, + + add : function (input, val) { + var dur; + // switch args to support add('s', 1) and add(1, 's') + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { + dur = moment.duration(+val, input); + } else { + dur = moment.duration(input, val); + } + addOrSubtractDurationFromMoment(this, dur, 1); + return this; + }, + + subtract : function (input, val) { + var dur; + // switch args to support subtract('s', 1) and subtract(1, 's') + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { + dur = moment.duration(+val, input); + } else { + dur = moment.duration(input, val); + } + addOrSubtractDurationFromMoment(this, dur, -1); + return this; + }, + + diff : function (input, units, asFloat) { + var that = makeAs(input, this), + zoneDiff = (this.zone() - that.zone()) * 6e4, + diff, output; + + units = normalizeUnits(units); + + if (units === 'year' || units === 'month') { + // average number of days in the months in the given dates + diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2 + // difference in months + output = ((this.year() - that.year()) * 12) + (this.month() - that.month()); + // adjust by taking difference in days, average number of days + // and dst in the given months. + output += ((this - moment(this).startOf('month')) - + (that - moment(that).startOf('month'))) / diff; + // same as above but with zones, to negate all dst + output -= ((this.zone() - moment(this).startOf('month').zone()) - + (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff; + if (units === 'year') { + output = output / 12; + } + } else { + diff = (this - that); + output = units === 'second' ? diff / 1e3 : // 1000 + units === 'minute' ? diff / 6e4 : // 1000 * 60 + units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60 + units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst + units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst + diff; + } + return asFloat ? output : absRound(output); + }, + + from : function (time, withoutSuffix) { + return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix); + }, + + fromNow : function (withoutSuffix) { + return this.from(moment(), withoutSuffix); + }, + + calendar : function (time) { + // We want to compare the start of today, vs this. + // Getting start-of-today depends on whether we're zone'd or not. + var now = time || moment(), + sod = makeAs(now, this).startOf('day'), + diff = this.diff(sod, 'days', true), + format = diff < -6 ? 'sameElse' : + diff < -1 ? 'lastWeek' : + diff < 0 ? 'lastDay' : + diff < 1 ? 'sameDay' : + diff < 2 ? 'nextDay' : + diff < 7 ? 'nextWeek' : 'sameElse'; + return this.format(this.lang().calendar(format, this)); + }, + + isLeapYear : function () { + return isLeapYear(this.year()); + }, + + isDST : function () { + return (this.zone() < this.clone().month(0).zone() || + this.zone() < this.clone().month(5).zone()); + }, + + day : function (input) { + var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); + if (input != null) { + input = parseWeekday(input, this.lang()); + return this.add({ d : input - day }); + } else { + return day; + } + }, + + month : makeAccessor('Month', true), + + startOf: function (units) { + units = normalizeUnits(units); + // the following switch intentionally omits break keywords + // to utilize falling through the cases. + switch (units) { + case 'year': + this.month(0); + /* falls through */ + case 'quarter': + case 'month': + this.date(1); + /* falls through */ + case 'week': + case 'isoWeek': + case 'day': + this.hours(0); + /* falls through */ + case 'hour': + this.minutes(0); + /* falls through */ + case 'minute': + this.seconds(0); + /* falls through */ + case 'second': + this.milliseconds(0); + /* falls through */ + } + + // weeks are a special case + if (units === 'week') { + this.weekday(0); + } else if (units === 'isoWeek') { + this.isoWeekday(1); + } + + // quarters are also special + if (units === 'quarter') { + this.month(Math.floor(this.month() / 3) * 3); + } + + return this; + }, + + endOf: function (units) { + units = normalizeUnits(units); + return this.startOf(units).add((units === 'isoWeek' ? 'week' : units), 1).subtract('ms', 1); + }, + + isAfter: function (input, units) { + units = typeof units !== 'undefined' ? units : 'millisecond'; + return +this.clone().startOf(units) > +moment(input).startOf(units); + }, + + isBefore: function (input, units) { + units = typeof units !== 'undefined' ? units : 'millisecond'; + return +this.clone().startOf(units) < +moment(input).startOf(units); + }, + + isSame: function (input, units) { + units = units || 'ms'; + return +this.clone().startOf(units) === +makeAs(input, this).startOf(units); + }, + + min: deprecate( + "moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other < this ? this : other; + } + ), + + max: deprecate( + "moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other > this ? this : other; + } + ), + + // keepTime = true means only change the timezone, without affecting + // the local hour. So 5:31:26 +0300 --[zone(2, true)]--> 5:31:26 +0200 + // It is possible that 5:31:26 doesn't exist int zone +0200, so we + // adjust the time as needed, to be valid. + // + // Keeping the time actually adds/subtracts (one hour) + // from the actual represented time. That is why we call updateOffset + // a second time. In case it wants us to change the offset again + // _changeInProgress == true case, then we have to adjust, because + // there is no such time in the given timezone. + zone : function (input, keepTime) { + var offset = this._offset || 0; + if (input != null) { + if (typeof input === "string") { + input = timezoneMinutesFromString(input); + } + if (Math.abs(input) < 16) { + input = input * 60; + } + this._offset = input; + this._isUTC = true; + if (offset !== input) { + if (!keepTime || this._changeInProgress) { + addOrSubtractDurationFromMoment(this, + moment.duration(offset - input, 'm'), 1, false); + } else if (!this._changeInProgress) { + this._changeInProgress = true; + moment.updateOffset(this, true); + this._changeInProgress = null; + } + } + } else { + return this._isUTC ? offset : this._d.getTimezoneOffset(); + } + return this; + }, + + zoneAbbr : function () { + return this._isUTC ? "UTC" : ""; + }, + + zoneName : function () { + return this._isUTC ? "Coordinated Universal Time" : ""; + }, + + parseZone : function () { + if (this._tzm) { + this.zone(this._tzm); + } else if (typeof this._i === 'string') { + this.zone(this._i); + } + return this; + }, + + hasAlignedHourOffset : function (input) { + if (!input) { + input = 0; + } + else { + input = moment(input).zone(); + } + + return (this.zone() - input) % 60 === 0; + }, + + daysInMonth : function () { + return daysInMonth(this.year(), this.month()); + }, + + dayOfYear : function (input) { + var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1; + return input == null ? dayOfYear : this.add("d", (input - dayOfYear)); + }, + + quarter : function (input) { + return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); + }, + + weekYear : function (input) { + var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year; + return input == null ? year : this.add("y", (input - year)); + }, + + isoWeekYear : function (input) { + var year = weekOfYear(this, 1, 4).year; + return input == null ? year : this.add("y", (input - year)); + }, + + week : function (input) { + var week = this.lang().week(this); + return input == null ? week : this.add("d", (input - week) * 7); + }, + + isoWeek : function (input) { + var week = weekOfYear(this, 1, 4).week; + return input == null ? week : this.add("d", (input - week) * 7); + }, + + weekday : function (input) { + var weekday = (this.day() + 7 - this.lang()._week.dow) % 7; + return input == null ? weekday : this.add("d", input - weekday); + }, + + isoWeekday : function (input) { + // behaves the same as moment#day except + // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) + // as a setter, sunday should belong to the previous week. + return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); + }, + + isoWeeksInYear : function () { + return weeksInYear(this.year(), 1, 4); + }, + + weeksInYear : function () { + var weekInfo = this._lang._week; + return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units](); + }, + + set : function (units, value) { + units = normalizeUnits(units); + if (typeof this[units] === 'function') { + this[units](value); + } + return this; + }, + + // If passed a language key, it will set the language for this + // instance. Otherwise, it will return the language configuration + // variables for this instance. + lang : function (key) { + if (key === undefined) { + return this._lang; + } else { + this._lang = getLangDefinition(key); + return this; + } + } + }); + + function rawMonthSetter(mom, value) { + var dayOfMonth; + + // TODO: Move this out of here! + if (typeof value === 'string') { + value = mom.lang().monthsParse(value); + // TODO: Another silent failure? + if (typeof value !== 'number') { + return mom; + } + } + + dayOfMonth = Math.min(mom.date(), + daysInMonth(mom.year(), value)); + mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); + return mom; + } + + function rawGetter(mom, unit) { + return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit](); + } + + function rawSetter(mom, unit, value) { + if (unit === 'Month') { + return rawMonthSetter(mom, value); + } else { + return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); + } + } + + function makeAccessor(unit, keepTime) { + return function (value) { + if (value != null) { + rawSetter(this, unit, value); + moment.updateOffset(this, keepTime); + return this; + } else { + return rawGetter(this, unit); + } + }; + } + + moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false); + moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false); + moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false); + // Setting the hour should keep the time, because the user explicitly + // specified which hour he wants. So trying to maintain the same hour (in + // a new timezone) makes sense. Adding/subtracting hours does not follow + // this rule. + moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true); + // moment.fn.month is defined separately + moment.fn.date = makeAccessor('Date', true); + moment.fn.dates = deprecate("dates accessor is deprecated. Use date instead.", makeAccessor('Date', true)); + moment.fn.year = makeAccessor('FullYear', true); + moment.fn.years = deprecate("years accessor is deprecated. Use year instead.", makeAccessor('FullYear', true)); + + // add plural methods + moment.fn.days = moment.fn.day; + moment.fn.months = moment.fn.month; + moment.fn.weeks = moment.fn.week; + moment.fn.isoWeeks = moment.fn.isoWeek; + moment.fn.quarters = moment.fn.quarter; + + // add aliased format methods + moment.fn.toJSON = moment.fn.toISOString; + + /************************************ + Duration Prototype + ************************************/ + + + extend(moment.duration.fn = Duration.prototype, { + + _bubble : function () { + var milliseconds = this._milliseconds, + days = this._days, + months = this._months, + data = this._data, + seconds, minutes, hours, years; + + // The following code bubbles up values, see the tests for + // examples of what that means. + data.milliseconds = milliseconds % 1000; + + seconds = absRound(milliseconds / 1000); + data.seconds = seconds % 60; + + minutes = absRound(seconds / 60); + data.minutes = minutes % 60; + + hours = absRound(minutes / 60); + data.hours = hours % 24; + + days += absRound(hours / 24); + data.days = days % 30; + + months += absRound(days / 30); + data.months = months % 12; + + years = absRound(months / 12); + data.years = years; + }, + + weeks : function () { + return absRound(this.days() / 7); + }, + + valueOf : function () { + return this._milliseconds + + this._days * 864e5 + + (this._months % 12) * 2592e6 + + toInt(this._months / 12) * 31536e6; + }, + + humanize : function (withSuffix) { + var difference = +this, + output = relativeTime(difference, !withSuffix, this.lang()); + + if (withSuffix) { + output = this.lang().pastFuture(difference, output); + } + + return this.lang().postformat(output); + }, + + add : function (input, val) { + // supports only 2.0-style add(1, 's') or add(moment) + var dur = moment.duration(input, val); + + this._milliseconds += dur._milliseconds; + this._days += dur._days; + this._months += dur._months; + + this._bubble(); + + return this; + }, + + subtract : function (input, val) { + var dur = moment.duration(input, val); + + this._milliseconds -= dur._milliseconds; + this._days -= dur._days; + this._months -= dur._months; + + this._bubble(); + + return this; + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units.toLowerCase() + 's'](); + }, + + as : function (units) { + units = normalizeUnits(units); + return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's'](); + }, + + lang : moment.fn.lang, + + toIsoString : function () { + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js + var years = Math.abs(this.years()), + months = Math.abs(this.months()), + days = Math.abs(this.days()), + hours = Math.abs(this.hours()), + minutes = Math.abs(this.minutes()), + seconds = Math.abs(this.seconds() + this.milliseconds() / 1000); + + if (!this.asSeconds()) { + // this is the same as C#'s (Noda) and python (isodate)... + // but not other JS (goog.date) + return 'P0D'; + } + + return (this.asSeconds() < 0 ? '-' : '') + + 'P' + + (years ? years + 'Y' : '') + + (months ? months + 'M' : '') + + (days ? days + 'D' : '') + + ((hours || minutes || seconds) ? 'T' : '') + + (hours ? hours + 'H' : '') + + (minutes ? minutes + 'M' : '') + + (seconds ? seconds + 'S' : ''); + } + }); + + function makeDurationGetter(name) { + moment.duration.fn[name] = function () { + return this._data[name]; + }; + } + + function makeDurationAsGetter(name, factor) { + moment.duration.fn['as' + name] = function () { + return +this / factor; + }; + } + + for (i in unitMillisecondFactors) { + if (unitMillisecondFactors.hasOwnProperty(i)) { + makeDurationAsGetter(i, unitMillisecondFactors[i]); + makeDurationGetter(i.toLowerCase()); + } + } + + makeDurationAsGetter('Weeks', 6048e5); + moment.duration.fn.asMonths = function () { + return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12; + }; + + + /************************************ + Default Lang + ************************************/ + + + // Set default language, other languages will inherit from English. + moment.lang('en', { + ordinal : function (number) { + var b = number % 10, + output = (toInt(number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + return number + output; + } + }); + + /* EMBED_LANGUAGES */ + + /************************************ + Exposing Moment + ************************************/ + + function makeGlobal(shouldDeprecate) { + /*global ender:false */ + if (typeof ender !== 'undefined') { + return; + } + oldGlobalMoment = globalScope.moment; + if (shouldDeprecate) { + globalScope.moment = deprecate( + "Accessing Moment through the global scope is " + + "deprecated, and will be removed in an upcoming " + + "release.", + moment); + } else { + globalScope.moment = moment; + } + } + + // CommonJS module is defined + if (hasModule) { + module.exports = moment; + } else if (typeof define === "function" && define.amd) { + define("moment", function (require, exports, module) { + if (module.config && module.config() && module.config().noGlobal === true) { + // release the global variable + globalScope.moment = oldGlobalMoment; + } + + return moment; + }); + makeGlobal(true); + } else { + makeGlobal(); + } +}).call(this); \ No newline at end of file diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 28f721349..13ec1161b 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -49,6 +49,7 @@ return [ 'user' => [ 'name' => 'Administrator', 'menu_label' => 'Administrators', + 'menu_description' => 'Manage back-end administrator users, groups and permissions.', 'list_title' => 'Manage Administrators', 'new' => 'New Administrator', 'login' => "Login", @@ -178,6 +179,7 @@ return [ 'myaccount' => [ 'menu_label' => 'My Account', 'menu_description' => 'Update your account details such as name, email address and password.', + 'menu_keywords' => 'security login' ], 'backend_preferences' => [ 'menu_label' => 'Backend Preferences', diff --git a/modules/backend/layouts/_head.htm b/modules/backend/layouts/_head.htm index 8dceb3af1..fc61b28d6 100644 --- a/modules/backend/layouts/_head.htm +++ b/modules/backend/layouts/_head.htm @@ -18,6 +18,8 @@ + + @@ -69,7 +71,7 @@ - +