From c3737018e064a81c8a0654e232db9c3835db8455 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 7 Aug 2013 12:27:50 +1000 Subject: [PATCH] Fixes overflow on dialogs when there too much content, fixes date format for content mocks. --- .../lib/umbraco/Extensions.js | 87 ++++-- .../src/common/mocks/resources/_utils.js | 6 +- .../src/less/modals.less | 4 + .../views/propertyeditors/grid/iframe.html | 2 +- .../umbraco/lib/Umbraco/Extensions.js | 263 ------------------ src/umbraco.sln | 3 + 6 files changed, 71 insertions(+), 294 deletions(-) delete mode 100644 src/Umbraco.Web.UI/umbraco/lib/Umbraco/Extensions.js diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/Extensions.js b/src/Umbraco.Web.UI.Client/lib/umbraco/Extensions.js index e19438d3ef..057b772d7a 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/Extensions.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/Extensions.js @@ -1,14 +1,39 @@ (function () { - //extensions to base classes such as String and extension methods for jquery. - //NOTE: jquery must be loaded before this file. - - + //JavaScript extension methods on the core JavaScript objects (like String, Date, etc...) + if (!Date.prototype.toIsoDateTimeString) { + /** Converts a Date object to a globally acceptable ISO string, NOTE: This is different from the built in + JavaScript toISOString method which returns date/time like "2013-08-07T02:04:11.487Z" but we want "yyyy-MM-dd HH:mm:ss" */ + Date.prototype.toIsoDateTimeString = function (str) { + var month = this.getMonth(); + if (month.length === 1) { + month = "0" + month; + } + var day = this.getDate(); + if (day.length === 1) { + day = "0" + day; + } + var hour = this.getHours(); + if (hour.length === 1) { + hour = "0" + hour; + } + var mins = this.getMinutes(); + if (mins.length === 1) { + mins = "0" + mins; + } + var secs = this.getSeconds(); + if (secs.length === 1) { + secs = "0" + secs; + } + return this.getFullYear() + "-" + month + "-" + day + " " + hour + ":" + mins + ":" + secs; + }; + } //create guid method on the String if (String.CreateGuid == null) { - String.CreateGuid = function () { - ///generates a new Guid + + /** generates a new Guid */ + String.CreateGuid = function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); @@ -17,9 +42,9 @@ } if (!window.__debug__) { + + /** global method to send debug statements to console that is cross browser (or at least checks if its possible)*/ window.__debug__ = function (msg, category, isErr) { - ///global method to send debug statements to console that is cross browser (or at least checks if its possible) - if (((typeof console) != "undefined") && console.log && console.error) { if (isErr) console.error(category + ": " + msg); else console.log(category + ": " + msg); @@ -28,24 +53,24 @@ } if (!String.prototype.startsWith) { - String.prototype.startsWith = function (str) { - ///startsWith extension method for string - + /** startsWith extension method for string */ + String.prototype.startsWith = function (str) { return this.substr(0, str.length) === str; }; } if (!String.prototype.endsWith) { - String.prototype.endsWith = function (str) { - ///endsWith extension method for string - + + /** endsWith extension method for string*/ + String.prototype.endsWith = function (str) { return this.substr(this.length - str.length) === str; }; } if (!String.prototype.trimStart) { + + /** trims the start of the string*/ String.prototype.trimStart = function (str) { - ///trims the start of the string if (this.startsWith(str)) { return this.substring(str.length); } @@ -54,9 +79,9 @@ } if (!String.prototype.utf8Encode) { - String.prototype.utf8Encode = function () { - ///UTF8 encoder for string + /** UTF8 encoder for string*/ + String.prototype.utf8Encode = function () { var str = this.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < str.length; n++) { @@ -79,6 +104,8 @@ } if (!String.prototype.utf8Decode) { + + /** UTF8 decoder for string*/ String.prototype.utf8Decode = function () { var utftext = this; var string = ""; @@ -112,9 +139,9 @@ } if (!String.prototype.base64Encode) { + + /** Base64 encoder for string*/ String.prototype.base64Encode = function () { - ///Base64 encoder for string - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; @@ -150,8 +177,9 @@ } if (!String.prototype.base64Decode) { + + /** Base64 decoder for string*/ String.prototype.base64Decode = function () { - ///Base64 decoder for string var input = this; var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; @@ -191,16 +219,17 @@ if (!Math.randomRange) { + + /** randomRange extension for math*/ Math.randomRange = function (from, to) { - ///randomRange extension for math - return Math.floor(Math.random() * (to - from + 1) + from); }; } if (!String.prototype.toCamelCase) { + + /** toCamelCase extension method for string*/ String.prototype.toCamelCase = function () { - ///toCamelCase extension method for string var s = this.toPascalCase(); if ($.trim(s) == "") @@ -220,9 +249,10 @@ } if (!String.prototype.toPascalCase) { + + /** toPascalCase extension method for string*/ String.prototype.toPascalCase = function () { - ///toPascalCase extension method for string - + var s = ""; $.each($.trim(this).split(/[\s\.-]+/g), function (idx, val) { if ($.trim(val) == "") @@ -237,15 +267,18 @@ } if (!String.prototype.toUmbracoAlias) { + + /** toUmbracoAlias extension method for string*/ String.prototype.toUmbracoAlias = function () { - //////toUmbracoAlias extension method for string - + var s = this.replace(/[^a-zA-Z0-9\s\.-]+/g, ''); // Strip none alphanumeric chars return s.toCamelCase(); // Convert to camelCase }; } if (!String.prototype.toFunction) { + + /** Converts a string into a function if it is found */ String.prototype.toFunction = function () { var arr = this.split("."); var fn = (window || this); diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js index c512f84f27..07ffd2eeb2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/_utils.js @@ -11,9 +11,9 @@ getMockContent: function(id) { var node = { name: "My content with id: " + id, - updateDate: new Date(), - publishDate: new Date(), - createDate: new Date(), + updateDate: new Date().toIsoDateTimeString(), + publishDate: new Date().toIsoDateTimeString(), + createDate: new Date().toIsoDateTimeString(), id: id, parentId: 1234, icon: "icon-file-alt", diff --git a/src/Umbraco.Web.UI.Client/src/less/modals.less b/src/Umbraco.Web.UI.Client/src/less/modals.less index 07149a27a5..ed9d73cf19 100644 --- a/src/Umbraco.Web.UI.Client/src/less/modals.less +++ b/src/Umbraco.Web.UI.Client/src/less/modals.less @@ -54,6 +54,10 @@ border-top: #efefef 1px solid } +.umb-dialog-body{ + overflow:auto; +} + .modal.fade.in{border: none !important; border-radius: none !important;} .umb-modal.fade { outline: none; diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/iframe.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/iframe.html index 999135f47d..3210b61fb3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/iframe.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/iframe.html @@ -63,7 +63,7 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/lib/Umbraco/Extensions.js b/src/Umbraco.Web.UI/umbraco/lib/Umbraco/Extensions.js deleted file mode 100644 index e19438d3ef..0000000000 --- a/src/Umbraco.Web.UI/umbraco/lib/Umbraco/Extensions.js +++ /dev/null @@ -1,263 +0,0 @@ -(function () { - - //extensions to base classes such as String and extension methods for jquery. - //NOTE: jquery must be loaded before this file. - - - - //create guid method on the String - if (String.CreateGuid == null) { - String.CreateGuid = function () { - ///generates a new Guid - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); - }; - } - - if (!window.__debug__) { - window.__debug__ = function (msg, category, isErr) { - ///global method to send debug statements to console that is cross browser (or at least checks if its possible) - - if (((typeof console) != "undefined") && console.log && console.error) { - if (isErr) console.error(category + ": " + msg); - else console.log(category + ": " + msg); - } - }; - } - - if (!String.prototype.startsWith) { - String.prototype.startsWith = function (str) { - ///startsWith extension method for string - - return this.substr(0, str.length) === str; - }; - } - - if (!String.prototype.endsWith) { - String.prototype.endsWith = function (str) { - ///endsWith extension method for string - - return this.substr(this.length - str.length) === str; - }; - } - - if (!String.prototype.trimStart) { - String.prototype.trimStart = function (str) { - ///trims the start of the string - if (this.startsWith(str)) { - return this.substring(str.length); - } - return this; - }; - } - - if (!String.prototype.utf8Encode) { - String.prototype.utf8Encode = function () { - ///UTF8 encoder for string - - var str = this.replace(/\r\n/g, "\n"); - var utftext = ""; - for (var n = 0; n < str.length; n++) { - var c = str.charCodeAt(n); - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if ((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - return utftext; - }; - } - - if (!String.prototype.utf8Decode) { - String.prototype.utf8Decode = function () { - var utftext = this; - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while (i < utftext.length) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if ((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i + 1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i + 1); - c3 = utftext.charCodeAt(i + 2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; - }; - } - - if (!String.prototype.base64Encode) { - String.prototype.base64Encode = function () { - ///Base64 encoder for string - - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - var input = this.utf8Encode(); - - while (i < input.length) { - - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - keyStr.charAt(enc1) + keyStr.charAt(enc2) + - keyStr.charAt(enc3) + keyStr.charAt(enc4); - - } - - return output; - }; - } - - if (!String.prototype.base64Decode) { - String.prototype.base64Decode = function () { - ///Base64 decoder for string - - var input = this; - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = keyStr.indexOf(input.charAt(i++)); - enc2 = keyStr.indexOf(input.charAt(i++)); - enc3 = keyStr.indexOf(input.charAt(i++)); - enc4 = keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - - } - - return output.utf8Decode(); - - }; - } - - - if (!Math.randomRange) { - Math.randomRange = function (from, to) { - ///randomRange extension for math - - return Math.floor(Math.random() * (to - from + 1) + from); - }; - } - - if (!String.prototype.toCamelCase) { - String.prototype.toCamelCase = function () { - ///toCamelCase extension method for string - - var s = this.toPascalCase(); - if ($.trim(s) == "") - return ""; - if (s.length > 1) { - var regex = /^([A-Z]*)([A-Z].*)/g; - if (s.match(regex)) { - var match = regex.exec(s); - s = match[1].toLowerCase() + match[2]; - s = s.substr(0, 1).toLowerCase() + s.substr(1); - } - } else { - s = s.toLowerCase(); - } - return s; - }; - } - - if (!String.prototype.toPascalCase) { - String.prototype.toPascalCase = function () { - ///toPascalCase extension method for string - - var s = ""; - $.each($.trim(this).split(/[\s\.-]+/g), function (idx, val) { - if ($.trim(val) == "") - return; - if (val.length > 1) - s += val.substr(0, 1).toUpperCase() + val.substr(1); - else - s += val.toUpperCase(); - }); - return s; - }; - } - - if (!String.prototype.toUmbracoAlias) { - String.prototype.toUmbracoAlias = function () { - //////toUmbracoAlias extension method for string - - var s = this.replace(/[^a-zA-Z0-9\s\.-]+/g, ''); // Strip none alphanumeric chars - return s.toCamelCase(); // Convert to camelCase - }; - } - - if (!String.prototype.toFunction) { - String.prototype.toFunction = function () { - var arr = this.split("."); - var fn = (window || this); - for (var i = 0, len = arr.length; i < len; i++) { - fn = fn[arr[i]]; - } - if (typeof fn !== "function") { - throw new Error("function not found"); - } - return fn; - }; - } - - -})(); \ No newline at end of file diff --git a/src/umbraco.sln b/src/umbraco.sln index 40e367de59..1a81193e57 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -181,4 +181,7 @@ Global {73529637-28F5-419C-A6BB-D094E39DE614} = {DD32977B-EF54-475B-9A1B-B97A502C6E58} {B555AAE6-0F56-442F-AC9F-EF497DB38DE7} = {DD32977B-EF54-475B-9A1B-B97A502C6E58} EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal