1var _cpTranslationsHelper = { 2 translations: null, 3 indexer: null, 4 translateOptionTagsFromCpTieredSelectorSingle: function (result) { 5 this.setIndexer(); 6 if (this.indexer && this.indexer.length > 0 && typeof result === 'string' && result.trim().length > 0) { 7 var $el = $(result); 8 if ($el.length === 0) return result; 9 var obj = this; 10 $el.find('option').each(function () { 11 var $this = $(this); 12 var txt = $(this).text(); 13 if (obj.indexer.indexOf(txt) >= 0) $this.text(obj.translations[txt]); 14 }); 15 return $el[0].outerHTML; 16 } 17 return result; 18 }, 19 translateLabelTagsFromCpTieredSelectorMultiple: function (result) { 20 this.setIndexer(); 21 if (this.indexer && this.indexer.length > 0 && typeof result === 'string' && result.trim().length > 0) { 22 var $el = $(result); 23 if ($el.length === 0) return result; 24 var obj = this; 25 var html = ''; 26 $el.each(function () { 27 var $this = $(this); 28 var $labels = $this.find('label'); 29 $labels.each(function () { 30 var $lbl = $(this); 31 var txt = $lbl.text(); 32 if (obj.indexer.indexOf(txt) >= 0) $lbl.text(obj.translations[txt]); 33 }); 34 html += $this[0].outerHTML;; 35 }); 36 return html; 37 } 38 return result; 39 }, 40 setIndexer: function () { 41 if (this.indexer == null && this.translations && typeof this.translations === 'object') { 42 var indexer = []; // only sets the indexer prop once. can quickly find if key is in array, then index the object by string to get value 43 for (var prop in this.translations) { 44 if (Object.prototype.hasOwnProperty.call(this.translations, prop)) { 45 indexer.push(prop); 46 } 47 } 48 this.indexer = indexer; 49 } 50 } 51}; 52function CpAttributeSwitch_ExecutePlugins(clientId, isAsyncPostback) { 53 //console.log("CpAttributeSwitch_ExecutePlugins"); 54 if ((typeof toolboxDroppable !== 'undefined') && !!toolboxDroppable) { 55 $(".ConsoleFormInput input:text, .ConsoleFormInput textarea:not(.reTextArea), .ConsoleFormInput .RadEditor").droppable(toolboxDroppable); 56 } 57 if (isAsyncPostback) { 58 setTimeout(function () { // setTimeout waits for the editors to load before setting the focus 59 $('#' + clientId + ' :checked').focus(); 60 }, 0); 61 } 62} 63 64function CpLengthValidatorIsValid(val) { 65 var value = ValidatorGetValue(val.controltovalidate); 66 if (ValidatorTrim(value).length == 0) return true; 67 if (val.maximumlength < 0) return true; 68 return (value.length <= val.maximumlength); 69} 70 71function cpAudienceSelector_CheckChanged(source, clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams) { 72 var hiddenField = $get(hiddenFieldId); 73 var checkbox = $get('cbx' + clientId); 74 var checkbox2 = $get('cbx' + clientId + '2'); 75 76 hiddenField.value = hiddenField.value.toLowerCase(); 77 var values = hiddenField.value.split(', '); 78 79 var params = addParams.split('|'); 80 var forceRoot = ((params.length >= 3) && (params[2] == 'true')); 81 var uncheckDependency = ((params.length >= 4) && (params[3] == 'true')); 82 if (checkbox2 != null) { 83 if (uncheckDependency) { 84 if ((source.id == checkbox2.id) && !checkbox.disabled && !checkbox.checked && checkbox2.checked) checkbox.checked = true; // when checkbox 2 is checked make sure checkbox 1 is also checked 85 if ((source.id == checkbox.id) && !checkbox2.disabled && !checkbox.checked && checkbox2.checked) checkbox2.checked = false; // when checkbox 1 is unchecked make sure checkbox 2 is also unchecked 86 } else { 87 if ((source.id == checkbox.id) && !checkbox2.disabled && checkbox.checked && !c
87heckbox2.checked) checkbox2.checked = true; // when checkbox 1 is checked make sure checkbox 2 is also checked 88 } 89 } else { 90 checkbox2 = checkbox; 91 } 92 93 var all = 'bf7bb52f-eae7-4d5a-bd20-6849d0260c80', root = '5f2d099d-a0df-4e62-bb88-93662c972ae0'; 94 if (checkbox.value == all) { 95 var divRoot = $get('div' + clientId.replace(all, root)); 96 if (divRoot != null) { 97 if (checkbox.checked && checkbox2.checked) { 98 hiddenField.value = all + ':1:1'; 99 if (forceRoot) { 100 hiddenField.value += ', ' + root + ':0:1'; 101 var cbxRootPublish = $get(checkbox.id.replace(all, root)); 102 if (cbxRootPublish != null) cbxRootPublish.checked = false; 103 } 104 divRoot.style.display = 'none'; 105 cpTieredSelector_ResizeDiv(clientId.substring(0, clientId.indexOf('__input'))); 106 } else { 107 hiddenField.value = (checkbox.checked || checkbox2.checked) ? checkbox.value + ':' + cpAudienceSelector_ConvertBool(checkbox.checked) + ':' + cpAudienceSelector_ConvertBool(checkbox2.checked) : ''; 108 for (var i = 0; i < values.length; i++) { 109 var len = values[i].trim().length; 110 if (len >= 36) { 111 var id = values[i].substring(0, 36).toLowerCase(); 112 if (id != checkbox.value.toLowerCase()) { 113 var publish = (len >= 38) ? values[i].substring(37, 38) : '0'; 114 if (checkbox.checked) publish = '0'; 115 var edit = (len >= 40) ? values[i].substring(39, 40) : '0'; 116 if (forceRoot && (id == root)) edit = '1'; else if (checkbox2.checked) edit = '0'; 117 if (hiddenField.value != '') hiddenField.value += ', '; 118 hiddenField.value += (id + ':' + publish + ':' + edit); 119 } 120 } 121 } 122 divRoot.style.display = 'block'; 123 var cbxRootPublish = $get(checkbox.id.replace(all, root)); 124 if (cbxRootPublish != null) { 125 cbxRootPublish.disabled = checkbox.checked; 126 if (checkbox.checked) cbxRootPublish.checked = false; 127 } 128 Centralpoint.Web.UI.WebServices.TieredSelector.Render(index, success, tableName, textField, valueField, parentField, root, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, hiddenField.value, false, enabled, addParams, eval(success)); 129 } 130 } 131 } else { 132 var allPublish = false; var allEdit = false; 133 hiddenField.value = ''; 134 for (var i = 0; i < values.length; i++) { 135 var len = values[i].trim().length; 136 if (len >= 36) { 137 var id = values[i].substring(0, 36); 138 if (id != checkbox.value.toLowerCase()) { 139 if (hiddenField.value != '') hiddenField.value += ', '; 140 hiddenField.value += values[i]; 141 if (id == all) { 142 allPublish = (len >= 38) ? (values[i].substring(37, 38) == '1') : true; 143 allEdit = (len >= 40) ? (values[i].substring(39, 40) == '1') : true; 144 } 145 } 146 } 147 } 148 149 var publish = (allPublish) ? '0' : cpAudienceSelector_ConvertBool(checkbox.checked); 150 var edit = (allEdit) ? '0' : cpAudienceSelector_ConvertBool(checkbox2.checked); 151 if (forceRoot && (checkbox.value.toLowerCase() == root)) edit = '1'; 152 if ((publish == '1') || (edit == '1')) { 153 if (hiddenField.value != '') hiddenField.value += ', '; 154 hiddenField.value += (checkbox.value + ':' + publish + ':' + edit); 155 } 156 } 157 158 cpTieredSelector_CheckChangedBase(source, clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams); 159} 160 161function cpAudienceSelector_ConvertBool(value) { 162 if (value) return '1'; else return '0'; 163} 164 165function cpPagedListBox_CheckChanged(source, hiddenFieldId, countLinkId, isSingle) { 166 var hiddenField = $get(hiddenFieldId); 167 168 if (isSingle) { 169 hiddenField.value = source.value; 170 } else { 171 var values = hiddenField.value.split(', '); 172 hiddenField.value = source.checked ? source.value : ''; 173 for (var i = 0; i < values.length; i++) { 174 if ((values[i].trim() != '') && (values[i].toLowerCase() != source.value.toLowerCase())) { 175 if (hiddenField.value != '') hiddenField.value += ', '; 176 hiddenField.value += values[i]; 177 } 178 } 179 } 180 181 cpPagedListBox_SetSelectedItemCount(hiddenField, countLinkId); 182} 183 184function cpPagedListBox_CheckAll(source, hiddenFieldId, countLinkId, controlId) { 185 var hiddenField = $get(hiddenFieldId); 186 var control = $get(controlId); 187 var groupName = controlId + '_Selector'; 188 189 var checkboxes = control.getElementsByTagName('input'); 190 if (source.checked) { 191 var originalValue = hiddenField.value.toLowerCase(); 192 for (var i = 0; i < checkboxes.length; i++) { 193 if (checkboxes[i].name == groupName) { 194 checkboxes[i].checked = true; 195 if (originalValue.indexOf(checkboxes[i].value.toLowerCase()) < 0) { 196 if (hiddenField.value != '') hiddenField.value += ', '; 197 hiddenField.value += checkboxes[i].value; 198 } 199 } 200 } 201 } else { 202 var unchecked = ''; 203 for (var i = 0; i < checkboxes.length; i++) { 204 if (checkboxes[i].name == groupName) { 205 checkboxes[i].checked = false; 206 if (unchecked != '') unchecked += ', '; 207 unchecked += checkboxes[i].value; 208 } 209 } 210 unchecked = unchecked.toLowerCase(); 211 var values = hiddenField.value.split(', '); 212 hiddenField.value = ''; 213 for (var i = 0; i < values.length; i++) { 214 if ((values[i].trim() != '') && (unchecked.indexOf(values[i].toLowerCase()) < 0)) { 215 if (hiddenField.value != '') hiddenField.value += ', '; 216 hiddenField.value += values[i]; 217 } 218 } 219 } 220 221 //alert(hiddenField.value); 222 cpPagedListBox_SetSelectedItemCount(hiddenField, countLinkId); 223} 224 225function cpPagedListBox_SetSelectedItemCount(hiddenField, countLinkId) { 226 var countLink = $get(countLinkId); 227 228 if (countLink != null) {
229 //var count = Math.ceil(hiddenField.value.length / 38); 230 var count = (hiddenField.value.length <= 0) ? 0 : hiddenField.value.split(",").length; 231 countLink.innerHTML = count + ' Selected Item'; 232 if (count != 1) countLink.innerHTML += 's'; 233 if (count <= 0) 234 $(countLink).on('click', function () { return false; }); 235 else 236 $(countLink).off('click'); 237 } 238} 239 240function cpPagedListBox_OnClientLoad(clientId, scrollDivId, maxHeight) { 241 var scrollDiv = $get(scrollDivId); 242 scrollDiv.style.height = (scrollDiv.scrollHeight > maxHeight) || (scrollDiv.scrollHeight === 0 && maxHeight > 0) ? maxHeight + 'px' : 'auto'; // 2nd condition occurs when iframe is loaded on page within a hidden element & allows it to maintain its property settings 243 scrollDiv.style.width = '100%'; 244 $('#' + clientId).find('a, .CpPagedListBoxSearch input, .CpPagedListBoxSearch select').attr('tabindex', '-1'); 245} 246 247function cpPagedListBox_ToggleProgressIndicator(progressDivId, display) { 248 var progressDiv = $get(progressDivId); 249 if (progressDiv != null) progressDiv.style.display = display ? 'block' : 'none'; 250} 251 252function CpUploadOpenDialog(type, subFolder, fieldId, previewId, title, isConsole, dialog, width, height, overwriteProtection) { 253 if (typeof isConsole == "undefined") isConsole = false; 254 if (typeof dialog == "undefined") dialog = '00'; 255 if (typeof width == "undefined") width = 900; 256 if (typeof height == "undefined") height = 600; 257 if (typeof overwriteProtection == "undefined") overwriteProtection = false; 258 var xpos = (screen.width - width) / 2; 259 var ypos = (screen.height - height) / 2; 260 var prefix = isConsole ? '/Console' : ''; 261 // the standard file upload url cannot always contain /Console/ because that would break it in the master and uber consoles 262 var url = (type == 'Resource') 263 ? '/Console/Resources.aspx?sn=Resources&type=control&fieldid=' + fieldId + '&previewid=' + previewId + '&title=' + encodeURIComponent(title) + '&debug=noupdatepanels&overwriteProtection=' + overwriteProtection 264 : prefix + '/Integrations/Centralpoint/FileUpload/Default.aspx?type=' + type + '&subfolder=' + subFolder + '&fieldid=' + fieldId + '&previewid=' + previewId + '&title=' + encodeURIComponent(title) + '&dialog=' + dialog + '&overwriteProtection=' + overwriteProtection; 265 window.open(url, 'FileUpload_' + fieldId, 'menubar=no,status=no,scrollbars=yes,resizable=yes,height=' + height + ',width=' + width + ',left=' + xpos + ',top=' + ypos + ',screenX=' + xpos + ',screenY=' + ypos + ',toolbar=no,location=no,directories=no'); 266 return false; 267} 268 269function CpUploadOpenDialogSafe(width, height, isConsole, target, dialog) { 270 if (typeof width == "undefined") width = 900; 271 if (typeof height == "undefined") height = 600; 272 //var xpos = (screen.width - width) / 2; 273 //var ypos = (screen.height - height) / 2; 274 var ypos = window.outerHeight / 2 + window.screenY - (height / 2) 275 var xpos = window.outerWidth / 2 + window.screenX - (width / 2) 276 var prefix = isConsole ? "/Console" : ""; 277 var url = prefix + "/Integrations/Centralpoint/FileUpload/Default.aspx?dialog=" + encodeURIComponent(dialog); 278 window.open(url, target, 'menubar=no,status=no,scrollbars=yes,resizable=yes,height=' + height + ',width=' + width + ',left=' + xpos + ',top=' + ypos + ',screenX=' + xpos + ',screenY=' + ypos + ',toolbar=no,location=no,directories=no'); 279 return false; 280} 281 282function CpUploadUpdatePreview(fieldId, previewId, ext, isConsole, isResource) { 283 var field = document.getElementById(fieldId); 284 var preview = document.getElementById(previewId); 285 if (typeof isConsole == "undefined") isConsole = false; 286 if (typeof isResource == "undefined") isResource = false; 287 var url = field.value; 288 289 if (url.startsWith('http') && CpUploadUpdatePreviewIsUrl(url)) { 290 preview.innerHTML += "<br />"; 291 preview.innerHTML += "<img src=\"" + url + "\" alt=\"" + url + "\" style=\"padding: 4px 0px 4px 0px;\" />"; 292 preview.style.display = 'block'; 293 } 294 else if (url.startsWith('/') && CpUploadUpdatePreviewIsUrl('http://oxcyon.com' + url)) { 295 if (typeof ext == "undefined") { 296 ext = url.substring(url.length - 4).toLowerCase(); 297 if (ext.charAt(0) == '.') ext = ext.substring(1); 298 } 299 300 var prefix = (isConsole && isResource) ? '/Console' : ''; 301 preview.innerHTML = "<a href=\"" + prefix + url + "\" target=\"_blank\">" + url + "</a>"; 302 switch (ext) { 303 case "jpg": 304 case "jpeg": 305 case "gif": 306 case "png": 307 preview.innerHTML += "<br />"; 308 if (isResource) 309 preview.innerHTML += "<img src=\"" + prefix + url + "&width=600\" alt=\"" + url + "\" style=\"padding: 4px 0px 4px 0px;\" />"; 310 else 311 preview.innerHTML += "<img src=\"" + prefix + url + "/600/0/false/Image.ashx\" alt=\"" + url + "\" style=\"padding: 4px 0px 4px 0px;\" />"; 312 break; 313 case "svg": 314 preview.innerHTML += '<br><img src="' + prefix + url + '" alt="' + url + '" style="padding: 4px 0; max-width: 600px;" />'; 315 break; 316 default: 317 break; 318 } 319 preview.style.display = 'block'; 320 } 321 else if ((url.startsWith('http') && !CpUploadUpdatePreviewIsUrl(url)) || (url.startsWith('/') && !CpUploadUpdatePreviewIsUrl('http://oxcyon.com' + url))) { 322 var imgPath = "/integrations/centralpoint/resources/control
322s/file_preview_unavailable.jpg"; 323 var imgPathHover = "/integrations/centralpoint/resources/controls/file_preview_unavailable_hover.jpg"; 324 var imgOnMouseOver = "$(this).attr('src','" + imgPathHover + "'); $(this).next('div').css('display', 'inline-block').show();" 325 var imgOnMouseOut = "$(this).attr('src','" + imgPath + "'); $(this).next('div').hide();" 326 var $img = "<img src=\"" + imgPath + "\" alt=\"File Preview Unavailable\" style=\"display: block;\" onmouseover=\"" + imgOnMouseOver + "\" onmouseout=\"" + imgOnMouseOut + "\">"; 327 var message = "Your file uploaded successfully. However, its name contains characters that are a security risk. It will behave normally for users viewing your site. Valid characters within a filename include a-z, A-Z, 0-9, %, _, ., ~, and + . Make sure your file name contains no spaces or characters besides these to preview."; 328 var messageStyles = "display: none; max-width: 600px; background: #FEF8E2; padding: 10px; margin: 0; line-height: 130 %; color: #000; border: 1px solid #000; box-shadow: 0 0 10px;"; 329 preview.innerHTML = "<div style=\"margin: 2px 0 0;\">" + $img + "<div style=\"" + messageStyles + "\">" + message + "</div>"; 330 preview.style.display = 'block'; 331 } 332 else if (url && !cp_uploadUpdatePreviewIsUrlEnabled) { 333 preview.innerHTML = "<p style=\"margin: 2px 0 0;\">" + url + "</p>"; 334 preview.style.display = 'block'; 335 } 336 else { 337 preview.style.display = 'none'; 338 } 339 $('#' + fieldId).trigger('change'); 340} 341 342function CpUploadUpdatePreviewIsUrl(url) { 343 if (!cp_uploadUpdatePreviewIsUrlEnabled) return true; 344 var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol 345 '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name 346 '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address 347 '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path 348 '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string 349 '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator 350 return !!pattern.test(url); 351} 352 353function CpOneDrivePickerPreview(fieldId, previewId) { 354 var value = $("#" + fieldId).val(); 355 //console.log("CpOneDrivePickerPreview", value); 356 if (!!value) { 357 var obj = JSON.parse(value); 358 var html = !obj.name ? obj.id : obj.name; 359 if (!!obj.webUrl) html = "<a href='" + obj.webUrl + "' target='onedrivepicker'>" + html + "</a>"; 360 $("#" + previewId).html(html); 361 } 362} 363 364if (typeof (Sys) != 'undefined') Sys.Application.notifyScriptLoaded(); // 2012-07-11: this line was formerly part of CpUpload.js but I have no idea what it does 365 366function CpEditor_ResourceManager(commandName, editor, oTool) { 367 //editor.showDialog('Media', {}, function (sender, args) { editor.pasteHtml(args.html); }); 368 var callbackFunction = function (sender, args) { editor.pasteHtml(args.html); } 369 //showExternalDialog(url, argument, width, height, callbackFunction, callbackArgs, title, modal, behaviors, showStatusbar, showTitlebar); 370 editor.showExternalDialog('/Console/RtfEditorDialog.aspx?view=Media', null, 640, 480, callbackFunction, null, 'Media Manager', true, Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true); 371} 372 373function CpEditor_WebSiteLinks(commandName, editor, oTool) { 374 //editor.showDialog('Links', {}, function (sender, args) { editor.pasteHtml(args.html); }); 375 var callbackFunction = function (sender, args) { editor.pasteHtml(args.html); } 376 //showExternalDialog(url, argument, width, height, callbackFunction, callbackArgs, title, modal, behaviors, showStatusbar, showTitlebar); 377 editor.showExternalDialog('/Console/RtfEditorDialog.aspx?view=Links', null, 640, 480, callbackFunction, null, 'Site Links', true, Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true); 378} 379 380function CpEditor_ScriptDesigner(commandName, editor, oTool) { 381 //console.log("CpEditor_ScriptDesigner", elem); 382 var script = null; 383 var preHtml = "", postHtml = ""; 384 var elem = editor.getSelectedElement(); 385 if (elem && (elem.tagName === "CODE")) { 386 $elem = $(elem); 387 if ($elem.data("generator") === "CpEditor") { 388 editor.selectElement(elem); 389 script = $elem.html(); 390 //console.log(elem, $elem[0]); 391 392 var start = script.indexOf('['); 393 if (start > 0) { 394 preHtml = script.substring(0, start); 395 script = script.substring(start); 396 //console.log(start, preHtml, script); 397 } 398 var end = script.indexOf("/]") + 2; 399 if (end < script.length) { 400 postHtml = script.substring(end); 401 script = script.substring(0, end); 402 //console.log(end, preHtml, script); 403 } 404 //console.log(script); 405 } 406 } 407 408 var callbackFunction = function (sender, args) { 409 editor.pasteHtml(preHtml + args.html + postHtml); 410 } 411 412 var moduleName = "Template"; 413 var views = ""; 414 if (typeof (cpsys) !== "undefined") { 415 if (typeof (cpsys.SiteMapInfo) !== "undefined") 416 moduleName = cpsys.SiteMapInfo.SystemName; 417 if (typeof (cpsys.ModuleViewsInfo) !== "undefined") 418 views = cpsys.ModuleViewsInfo.NavigationItemId + ':' + cpsys.ModuleViewsInfo.GroupId; 419 } 420 421 var width = 800, height = 600 422 if ((window.innerWidth > 1024) && (window.innerHeight > 768)) { width = 1024; height = 768; } 423 var url = "/Console/ScriptBuilder/Dialog.aspx?module=" + moduleName + "&views=" + views; 424 if (script != null) { 425 url += "&edit=1"; 426 if (CpEditor_EnableCpScriptingFilter == 1) { 427 //console.debug("add istext", CpEditor_EnableCpScriptingFilter); 428 url += "&istext=1"; // without this line right clicking to access the script builder and saving changes will insert double which makes them present in the saved code 429 } 430 } 431 editor.showExternalDialog(url, script, width, height, callbackFunction, null, "Script Designer", true, Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true); 432} 433 434function CpEditor_OnClientPasteHtml(sender, args) { 435 var commandName = args.get_commandName(); 436 if ((commandName == "InsertTable") || (commandName == "TableWizard")) { 437 var div = document.createElement("DIV"); 438 div.innerHTML = args.get_value(); 439 var table = div.firstChild; 440 if (table.cellSpacing == '') table.cellSpacing = '0'; 441 if (table.cellPadding == '') table.cellPadding = '0'; 442 table.className = 'cpsys_Table'; 443 args.set_value(div.innerHTML); 444 } 445 else if (commandName == "MediaManager") { //adding support for HTML5 ~JZ~ 9/9/15 446 var value = args.get_value(); 447 var width = $(value).attr('width'); 448 var height = $(value).attr('height'); 449 var fileName = $(value).find('param').attr('value'); 450 var ext = fileName.substring(fileName.indexOf('.') + 1).toLowerCase(); 451 //alert(width + "|" + height + "|" + fileName + "|" + ext); 452 453 var div = document.createElement("DIV"); 454 if (ext == "mp4" || ext == "webm" || ext == "ogv") { 455 if (ext == "ogv") { 456 ext = "ogg" 457 } 458 459 var video = "<video width='" + width + "' height='" + height + "' controls='controls'>"; 460 video += "<source src='" + fileName + "' type='video/" + ext + "' />"; 461 video += "Your browser does not support this video format, please <a href='" + fileName + "'>download the video</a>' to view. Please consider downloading a more recent browser!"; 462 video += "</video>"; 463 args.set_value(video);
464 } else if (ext == "mp3" || ext == "ogg" || ext == "wav") { 465 if (ext == "mp3") { 466 ext = "mpeg"; 467 } 468 //for audio can support mp3, ogg, and wav - audio/mpeg, audio/ogg, audio/wav 469 var audio = "<audio controls>"; 470 audio += "<source src='" + fileName + "' type='audio/" + ext + "' controls='controls'>"; 471 audio += "Your browser does not support the audio element. Please consider downloading a more recent browser."; 472 audio += "</audio>"; 473 //div.innerHTML = audio; 474 //args.set_value(div.innerHTML); 475 args.set_value(audio); 476 } else { 477 div.innerHTML = value; 478 } 479 } 480 else if ((CpEditor_EnableCpScriptingFilter > 0) && (commandName == "Paste")) { 481 var value = args.get_value(); 482 if (value.search(/\[cp:/ig) >= 0) { 483 //console.log(value); 484 var $replacement = $("<div />").html(value); 485 var setValue = false; 486 // remove spans created by Chrome from scripting code elements 487 $replacement.find("span").each(function (index) { 488 var $span = $(this); 489 if ($span.css("font-family") === "courier, monospace") { 490 var html = $span.html(); 491 //console.log(html); 492 $span.replaceWith(html); 493 setValue = true; 494 } 495 }); 496 // remove fonts created by IE from scripting code elements 497 $replacement.find("font[face='Courier New']").each(function (index) { 498 var $font = $(this); 499 var html = $font.html(); 500 //console.log(html); 501 $font.replaceWith(html); 502 setValue = true; 503 }); 504 if (setValue) args.set_value($replacement.html()); 505 } 506 } 507 508 if (commandName === 'Paste') { 509 // resolves problem where relative paths in href are automatically convert
509ing to absolute paths 510 var origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); 511 var filter = new Telerik.Web.UI.Editor.StripPathsFilter([origin]); //strip the domain name from the absolute path 512 var tempElem = document.createElement("SPAN"); 513 tempElem.innerHTML = args.get_value(); 514 var replaceElem = filter.getHtmlContent(tempElem); 515 args.set_value(replaceElem.innerHTML); //set the modified pasted content in the editor 516 } 517} 518 519function CpEditor_OnClientLoad(editor, args) { 520 // This method is only called in consoles. Root/Modules/Forms/Editor.aspx calls Editor.js/onClientLoad which has to be modified independently. Root/Modules/MailContactsCalendars/Common/Mail/MessageForm.aspx calls Mail.js/mccMail.editor_OnClientLoad. 521 522 //CpEditor_EnableCpScriptingFilter = 1; 523 var filtersManager = editor.get_filtersManager(); 524 filtersManager.add(new CpEditor_RemoveLastBrFilter()); 525 526 if (CpEditor_EnableCpScriptingFilter > 0) { 527 filtersManager.add(new CpEditor_CpScriptingFilter()); 528 editor.set_html(editor.get_html()); // trigger the getDesignContent filters on the initial page load, get_html(true) would also trigger the getHtmlContent filters, this does not execute the custom filters added below 529 530 var contextMenu = editor.getContextMenuByTagName("CODE"); 531 if (!contextMenu) return; 532 contextMenu.add_show(function () { 533 var $sel = $(editor.getSelectedElement()); 534 if (!$sel.hasClass("cpsys_Script")) { 535 var menuItems = contextMenu.get_items(); 536 menuItems[0].remove(); // the script designer is the only item on the element 537 } 538 }); 539 } 540 541 if (typeof CpEditor_Custom_OnClientLoad === 'function') CpEditor_Custom_OnClientLoad(editor, args); 542 543 if (editor.getToolByName("ScriptDesigner")) { 544 $editor = $(editor.get_mainTable()); 545 //console.log($editor.closest(".ConsoleFormInput").data("allowscripts")); 546 if (!$editor.closest(".ConsoleFormInput").data("allowscripts")) { 547 //console.log($editor.find("span.ScriptDesigner")); 548 $editor.find("span.ScriptDesigner").css({ opacity: 0.4 }).attr("title", "Not Supported"); 549 } 550 } 551 552 $('.reToolCell a, .reToolZone a').attr('tabindex', '-1'); 553} 554 555function CpEditor_OnClientSelectionChange(editor, args) { 556 if (CpEditor_EnableCpScriptingFilter < 2) return; 557 //console.log("CpEditor_OnClientSelectionChange", editor._clientStateFieldID, args); 558 559 var sel = editor.getSelection(); 560 var range = sel.getRange(true); // https://developer.mozilla.org/en-US/docs/Web/API/Range 561 if (!range) return; 562 563 if (!range.setStart) { // IE7/8 textRange 564 //console.log("IE8 Click", sel, range, sel.getBrowserSelection()); 565 if (sel.getBrowserSelection().type == "None") return; // prevent the initial browser load from triggering the replacement 566 var $content = $(editor.get_contentArea()); 567 if ($content.find(".cpsys_Script").length > 0) { 568 //console.log("IE8 Click", range, $content); 569 $content.html(editor.get_html(true, false)); 570 } 571 return; 572 } 573 574 var scriptSelector = "div.cpsys_Script"; 575 var $container = $(range.commonAncestorContainer).closest(scriptSelector); 576 //console.log("$container", $container); 577 if ($container.length == 1) { 578 //console.log('Common Ancestor Script'); 579 var $replacement = CpEditor_ReplaceScriptPreview($container); 580 //console.log($replacement[0]); 581 editor.selectElement($replacement[0]); 582 } else if (!range.collapsed) { 583 //console.log("range", range); 584 var selectRange = false; 585 var $start = $(range.startContainer).closest(scriptSelector); 586 if ($start.length == 1) { 587 //console.log('Start In Script') 588 var $replacement = CpEditor_ReplaceScriptPreview($start); 589 range.setStartBefore($replacement[0]); 590 selectRange = true; 591 } 592 var $end = $(range.endContainer).closest(scriptSelector); 593 if ($end.length == 1) { 594 //console.log('End In Script') 595 var $replacement = CpEditor_ReplaceScriptPreview($end); 596 range.setEndAfter($replacement[0]); 597 selectRange = true; 598 } 599 if (selectRange) sel.selectRange(range); 600 } 601} 602 603function CpEditor_ReplaceAllScriptPreviews(content) { 604 //var result = content.replace(/(<|<)div data-cpscript="open"([\s\S]*?)(<|<)div data-cpscript="close" data-generator="CpEditor" style="display:\s*none;" contenteditable="false" unselectable="on"(>|>)\/CpScript(<|<)\/div(>|>)/ig, function (match) { 605 var result = content.replace(/(<|<)div .*?data-cpscript="open".*?(>|>)([\s\S]*?)(<|<)div .*?data-cpscript="close".*?(>|>)\/CpScript(<|<)\/div(>|>)/ig, function (match) { 606 var $script = $("<div />").html(match); 607 var $source = $script.find(".cpsys_ScriptSource"); 608 return ($source.length == 1) ? $source.html() : match; // if a script contains more or less than 1 source element there must have been a partial selection or other problem and no change is made 609 });
610 result = result.replace(/(<|<)code .*?data-generator="CpEditor".*?(>|>)([\s\S]*?)(<|<)\/code(>|>)/ig, "$3"); 611 return result; 612} 613 614function CpEditor_ReplaceScriptPreview($script) { 615 var $next = $script.next(); 616 if ($next.data("cpscript") == "close") $next.remove(); 617 618 var $source = $script.find(".cpsys_ScriptSource").css("display", "inline"); 619 if ($source.length == 1) { 620 html = "<code class=\"cpsys_Script\" data-generator=\"CpEditor\">" + $source.html() + "</code>"; 621 } else { 622 html = $script.html(); 623 } 624 625 var $replacement = $(html); 626 $script.replaceWith($replacement); 627 return $replacement; 628} 629 630function cpTieredSelector_Change(source, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams) { 631 var selectedValue = source.options[source.selectedIndex].value; 632 var hiddenField = $get(hiddenFieldId); 633 634 var next = $get(hiddenFieldId + index); 635 if (next != null) cpTieredSelector_Remove(next.parentNode.parentNode, index, hiddenFieldId); 636 637 if (selectedValue == '') { 638 if (index <= 2) { 639 hiddenField.value = ''; 640 } else { 641 var previous = $get(hiddenFieldId + (index - 2)).childNodes[0]; 642 // when the value is set to nothing make sure that an inaccessible value is not inadvertantly selected 643 if (previous.options[previous.selectedIndex].text == 'Inaccessible Value') { 644 previous.options[0].selected = true; 645 cpTieredSelector_Change(previous, index - 1, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams); 646 return; 647 } 648 hiddenField.value = previous.options[previous.selectedIndex].value; 649 } 650 } else { 651 hiddenField.value = selectedValue; 652 Centralpoint.Web.UI.WebServices.TieredSelector.Render(index, success, tableName, textField, valueField, parentField, selectedValue, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, '', false, enabled, addParams, eval(success)); 653 } 654 655 // remove the inaccessible value node when the selection is changed 656 var last = source.length - 1; 657 if (last > 0) { 658 if (source.options[last].text == 'Inaccessible Value') { 659 source.remove(last); 660 source.parentNode.style.display = 'none'; 661 } 662 } 663 //alert('hiddenField.value: ' + hiddenField.value); 664} 665 666function cpTieredSelector_Remove(parentNode, index, hiddenFieldId) { 667 var i = index; 668 var selectorNode = $get(hiddenFieldId + i); 669 670 while (selectorNode != null) { 671 parentNode.removeChild(selectorNode.parentNode); 672 i++; 673 selectorNode = $get(hiddenFieldId + i); 674 } 675} 676 677function cpTieredSelector_SelectByValue(parentId, value) { 678 //alert(parentId + ' - ' + value); 679 var parent = $get(parentId); 680 681 // if the parent control is not available wait for it to become available 682 if (parent == null) { 683 setTimeout('cpTieredSelector_SelectByValue(\'' + parentId + '\', \'' + value.replace(/'/g, '\\\'') + '\')', 100); 684 return; 685 } 686 687 var source = parent.childNodes[0]; 688 var inaccessible = true; 689 for (var i = 0; i < source.options.length; i++) { 690 var option = source.options[i]; 691 if (option.value == value) { 692 option.selected = true; 693 inaccessible = false; 694 break; 695 } 696 } 697 698 // if the item doesn't exist add it to the selector as an inaccessible value 699 if (inaccessible) cpTieredSelector_AppendOption(source, 'Inaccessible Value', value, true); 700} 701 702function cpTieredSelector_AppendOption(source, text, value, selected) { 703 var option = document.createElement('option'); 704 option.text = text; 705 option.value = value; 706 option.selected = selected; 707 708 try { 709 source.add(option, null); // standards compliant; doesn't work in IE 710 } 711 catch (ex) { 712 source.add(option); // IE only 713 } 714} 715 716function cpTieredSelector_RenderAfterParent(index, success, tableName, textField, valueField, parentField, parentValue, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, parentId, listSelectionMode, force, enabled, addParams) { 717 if (parentId != '') { 718 var parent = $get(parentId); 719 720 // if the parent control is not available wait for it to become available 721 if (parent == null) { 722 setTimeout('cpTieredSelector_RenderAfterParent(' + index + ', \'' + success + '\', \'' + tableName + '\', \'' + textField.replace(/'/g, '\\\'') + '\', \'' + valueField + '\', \'' 723 + parentField + '\', \'' + parentValue + '\', \'' + filter.replace(/'/g, '\\\'') + '\', ' + hasAncestorsTable + ', ' + prefixFields + ', ' + useDev + ', \'' + hiddenFieldId + '\', \'' 724 + parentId + '\', \'' + listSelectionMode + '\', ' + force + ', ' + enabled + ', \'' + addParams + '\')', 100); 725 return; 726 } 727 }
728 setTimeout('Centralpoint.Web.UI.WebServices.TieredSelector.Render(' + index + ', \'' + success + '\', \'' + tableName + '\', \'' + textField.replace(/'/g, '\\\'') + '\', \'' + valueField + '\', \'' 729 + parentField + '\', \'' + parentValue + '\', \'' + filter.replace(/'/g, '\\\'') + '\', ' + hasAncestorsTable + ', ' + prefixFields + ', ' + useDev + ', \'' + hiddenFieldId + '\', \'' 730 + listSelectionMode + '\', \'\', ' + force + ', ' + enabled + ', \'' + addParams + '\', eval(' + success + '))', 100); 731} 732 733function cpTieredSelector_Toggle(clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams) { 734 var image = $get('img' + clientId); 735 var intSep = image.src.lastIndexOf('/') + 1; 736 var strSrc = image.src.substring(intSep).toLowerCase(); 737 if (strSrc != 'plus.gif') { 738 image.src = image.src.substring(0, intSep) + 'Plus.gif'; 739 $get('divc' + clientId).style.display = 'none'; 740 } else { 741 Centralpoint.Web.UI.WebServices.TieredSelector.Render(index, success, tableName, textField, valueField, parentField, $get('cbx' + clientId).value, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, $get(hiddenFieldId).value, false, enabled, addParams, eval(success)); 742 } 743} 744 745function cpTieredSelector_CheckChanged(source, clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams) { 746 var hiddenField = $get(hiddenFieldId); 747 var checkbox = $get('cbx' + clientId); 748 749 hiddenField.value = hiddenField.value.toLowerCase(); 750 var values = hiddenField.value.split(', '); 751 hiddenField.value = checkbox.checked ? checkbox.value : ''; 752 for (var i = 0; i < values.length; i++) { 753 if ((values[i].trim() != '') && (values[i] != checkbox.value.toLowerCase())) { 754 if (hiddenField.value != '') hiddenField.value += ', '; 755 hiddenField.value += values[i]; 756 } 757 } 758 759 cpTieredSelector_CheckChangedBase(source, clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams); 760} 761 762function cpTieredSelector_CheckChangedBase(source, clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams) { 763 var image = $get('img' + clientId); 764 var imageSrc = image.src.substring(image.src.lastIndexOf('/') + 1).toLowerCase(); 765 766 if (source.checked && (imageSrc == 'plus.gif')) 767 cpTieredSelector_Toggle(clientId, index, success, tableName, textField, valueField, parentField, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, selectionMode, enabled, addParams); 768} 769 770function cpTieredSelector_ExpandAfterParent(index, success, tableName, textField, valueField, parentField, parentValue, filter, hasAncestorsTable, prefixFields, useDev, hiddenFieldId, listSelectionMode, enabled, addParams) { 771 var childrenId = 'divc' + hiddenFieldId + '_' + index + '_' + parentValue; 772 var children = $get(childrenId); 773 //alert(parentValue + ': ' + (children == null)); 774 775 // if the parent control is not available wait for it to become available 776 if (children == null) { 777 setTimeout('cpTieredSelector_ExpandAfterParent(' + index + ', \'' + success + '\', \'' + tableName + '\', \'' + textField.replace(/'/g, '\\\'') + '\', \'' + valueField + '\', \'' 778 + parentField + '\', \'' + parentValue + '\', \'' + filter.replace(/'/g, '\\\'') + '\', ' + hasAncestorsTable + ', ' + prefixFields + ', ' + useDev + ', \'' 779 + hiddenFieldId + '\', \'' + listSelectionMode + '\', ' + enabled + ', \'' + addParams + '\')', 100); 780 return; 781 } 782 783 setTimeout('Centralpoint.Web.UI.WebServices.TieredSelector.Render(' + (index + 1) + ', \'' + success + '\', \'' + tableName + '\', \'' + textField.replace(/'/g, '\\\'') + '\', \'' + valueField + '\', \'' 784 + parentField + '\', \'' + parentValue + '\', \'' + filter.replace(/'/g, '\\\'') + '\', ' + hasAncestorsTable + ', ' + prefixFields + ', ' + useDev + ', \'' + hiddenFieldId + '\', \'' + listSelectionMode + '\', \'' 785 + $get(hiddenFieldId).value.replace(/'/g, '\\\'') + '\', false, ' + enabled + ', \'' + addParams + '\', eval(' + success + '))', 100); 786} 787 788function cpTieredSelector_ShowInaccessibleValuesItem(hiddenFieldId) { 789 var item = $get('div' + hiddenFieldId + '_1_[cp:placeholders key=\'InaccessibleValues\' /]'); 790 if (item == null) { 791 setTimeout('cpTieredSelector_ShowInaccessibleValuesItem(\'' + hiddenFieldId + '\')', 100); 792 return; 793 } 794 item.style.display = 'block'; 795} 796 797function cpTieredSelector_ToggleHeight(source, divId) { 798 var div = $get(divId); 799 if (source.title == 'Click here to limit the selector\'s height using scroll bars.') { 800 div.style.height = ''; 801 cpTieredSelector_ResizeDiv(divId);
802 source.src = '/Integrations/Centralpoint/Resources/Controls/CpTieredSelectorLimited.png'; 803 source.title = 'Click here to allow the selector to resize to fit it\'s contents.'; 804 } else { 805 div.style.height = 'auto'; 806 source.src = '/Integrations/Centralpoint/Resources/Controls/CpTieredSelectorDynamic.png'; 807 source.title = 'Click here to limit the selector\'s height using scroll bars.'; 808 } 809 return false; 810} 811 812function cpTieredSelector_ResizeDiv(divId, limit) { 813 if (limit == undefined) limit = 152; 814 var div = $get(divId); 815 if (div != null) { 816 if (div.style.height != 'auto') { 817 var height = div.scrollHeight; 818 if (height > limit) 819 height = limit; 820 else if (height < 15) 821 height = 15; 822 //alert(div.style.height + ' to ' + height); 823 div.style.height = height + 'px'; 824 } 825 } 826} 827 828function cpTieredSelector_UpArrows(div) { 829 $(div).find("span.CpTieredSelectorMultipleCheckBox-UpArrow").show().on("click", function (e) { 830 e.preventDefault(); 831 //console.log("cpTieredSelector_UpArrows", $(this).siblings("input.CpTieredSelectorMultipleCheckBox:enabled:not(:checked)")); 832 //$(this).siblings("input.CpTieredSelectorMultipleCheckBox:enabled:not(:checked)").prop("checked", true); 833 $(this).siblings("input.CpTieredSelectorMultipleCheckBox:enabled:not(:checked):first").trigger("click"); 834 cpTieredSelector_UpArrowsPropagate($(this).parent().parent().parent()); 835 }); 836} 837 838function cpTieredSelector_UpArrowsPropagate($div) { 839 if ($div.is(".CpTieredSelectorMultiple") || ($div.parents(".CpTieredSelectorMultiple").length <= 0)) return; 840 841 $div.children("input.CpTieredSelectorMultipleCheckBox:enabled:not(:checked):first").trigger("click"); 842 cpTieredSelector_UpArrowsPropagate($div.parent().parent()); 843 //console.log("cpTieredSelector_UpArrowsPropagate", $div.parent().parent()); 844} 845 846function cpListBox_GetSingleValue(source) { 847 return source.options[source.selectedIndex].value; 848} 849 850function cpListBox_GetMultipleValues(name) { 851 var checkbox = eval('document.forms[0].' + name); 852 if (checkbox.length == undefined) return checkbox.value; 853 var result = ''; 854 for (var i = 0; i < checkbox.length; i++) { 855 if (checkbox[i].checked) { 856 if (result.length > 0) result += ', '; 857 result += checkbox[i].value; 858 } 859 } 860 return result; 861} 862 863function cpListBox_GroupSelector(group, checked) { 864 for (i = 0; i < group.length; i++) { 865 if (!group[i].disabled) 866 group[i].checked = checked; 867 } 868} 869 870function cpListBox_LegendClick(element) { 871 $(element).siblings().toggle(); 872} 873 874function cpRadioButtonList_GetValue(name) { 875 var radio = eval('document.forms[0].' + name); 876 for (var i = 0; i < radio.length; i++) { 877 if (radio[i].checked) return radio[i].value; 878 } 879} 880 881function cpSourceEditor_SetBase64Inputs() { 882 $('.CpSourceEditor[data-objeval]').each(function () { 883 var $this = $(this); 884 var objEval = $this.data('objeval'); 885 if (!objEval) return; 886 887 // the container names its own hidden field, so this no longer depends on the two staying adjacent 888 var $input = $('#' + $this.data('ai-value-element')); 889 if ($input.length !== 1) return; 890 891 // monaco is absent whenever its bundle never parsed, and the fallback textarea holds the value 892 var editor = window[objEval.replace(/^window\./, '')]; 893 var value = editor ? editor.getValue() : $this.next('.CpSourceEditorFallback').val(); 894 if (typeof value !== 'string') return; 895 896 $input.val(btoa(unescape(encodeURIComponent(value)))); 897 }); 898} 899 900function cpSelect2_Init(id) { 901 // https://select2.org/data-sources/ajax 902 let $select = $('select.CpSelect2[data-context][id="' + id + '"]'); 903 if ($select.length === 0) return; // return immediately if $select isn't a valid HTML element
904 let context = $select.data('context'); 905 906 if (context == 'static') { 907 $select.select2(); 908 } else { 909 $select.select2({ 910 ajax: { 911 url: '/Integrations/Centralpoint/WebServices/CpSelect2.asmx/Handle', 912 type: 'POST', 913 contentType: "application/json; charset=utf-8", 914 dataType: 'json', 915 data: function (params) { 916 let value = $select.val(); 917 let requestData = { 918 term: params.term, 919 page: parseInt(params.page), 920 value: Array.isArray(value) ? value.join(', ') : value, 921 context: context, 922 }; 923 return JSON.stringify({ param: requestData }); 924 }, 925 processResults: function (data) { 926 let responseData = data.d; 927 return { 928 results: responseData.Results, 929 pagination: responseData.Pagination 930 }; 931 } 932 } 933 }); 934 } 935 936 // Handle hidden input for formstate and viewstate 937 let hiddenInputName = $select.attr('name'); 938 let $hiddenInput = $('<input>', { 939 type: 'hidden', 940 name: hiddenInputName, 941 value: '' 942 }); 943 944 cpSelect2_UpdateHiddenInput($select, $hiddenInput, hiddenInputName); 945 946 $select.on('change', function () { 947 cpSelect2_UpdateHiddenInput($select, $hiddenInput, hiddenInputName); 948 }); 949} 950 951function cpSelect2_UpdateHiddenInput(select, hiddenInput, hiddenInputName) { 952 let selectedOptionsCount = select.find('option:selected').length; 953 if (selectedOptionsCount === 0) { 954 if (select.next('input[type="hidden"][name="' + hiddenInputName + '"]').length === 0) { 955 select.after(hiddenInput); 956 } 957 } else { 958 select.next('input[type="hidden"][name="' + hiddenInputName + '"]').remove(); 959 } 960}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.