1/// <reference path="Framework.js" /> 2/// <reference path="Framework.js" /> 3 4/** 5* Class Page Manager allows us to manipulate the layout of portlets 6*/ 7 (function( LayoutManager, $) { 8 9 LayoutManager.draggableSelector; 10 LayoutManager.listContainerSelector; 11 12 LayoutManager.PageLayout; 13 LayoutManager.Globalization; 14 15 16 LayoutManager.HTML = {}; 17 LayoutManager.HTML.ColumnWrapper = "<div class=\"portlet-column portlet-column{0}\"></div>"; 18 LayoutManager.HTML.DraggableBar = "<div class='{0}'><p>{1}</p></div>"; 19 LayoutManager.HTML.DraggableListWrapper = "<ul class='{0}'></ul>"; 20 LayoutManager.HTML.DraggableListItemWrapper = "<li portletID='{0}' class='{1}'></li>"; 21 LayoutManager.HTML.DraggableEmptyListWrapper = "<ul class='{0} {1}'></ul>"; 22 LayoutManager.HTML.ErrorWrapper = "<span class=\"rearrange error\"> {0}</span>"; 23 LayoutManager.HTML.DraggableTitleWrapper = "<label id='{0}' class='{1}'>{2} Or <a href=\"javascript:__doPostBack('{3}','')\"> use this window</a> to rearrange without dragging.</label>"; 24 LayoutManager.HTML.DraggableTitleWrapper = "<span id='drag-title' class='drag-title'>{0}</span>"; 25 LayoutManager.HTML.DraggableLinkWrapper = "<a id='{0}'>{1}</a>"; 26 LayoutManager.HTML.DraggableButtonWrapper = "<input id='{0}' class='{1}' type=\"submit\" value=\"{2}\"></input>"; 27 28 LayoutManager.AccesibilityPopup = (function ($) { 29 // private variables 30 var pageLayout, 31 show, 32 config, 33 buildHtml, 34 globalizer, 35 moveAllToSelect, 36 getPortletPositions, 37 selectedOptionsOtherThen; 38 39 40 moveUpItem = function(optionsList) { 41 $(optionsList).find(":selected").each(function() { 42 $(this).insertBefore($(this).prev()); 43 }); 44 }; 45 46 moveDownItem = function(optionsList) { 47 $(optionsList).find(":selected").each(function() { 48 $(this).insertAfter($(this).next()); 49 }); 50 }; 51 52 selectedOptionsOtherThen = function (exludingList) { 53 //TODO: to restrict the selection withing the AccessibilityPopup 54 return $("#AccessiblityPopup select").filter(function(list) { 55 return $("#AccessiblityPopup select")[list] != exludingList; 56 }).find(":selected"); 57 }; 58 59 moveAllToSelect = function (optionsList) { 60 var itemstToMove = selectedOptionsOtherThen(optionsList); 61 // move the options to the new list. 62 $(itemstToMove).remove().appendTo(optionsList); 63 // clear selections 64 $(optionsList).val(''); 65 }; 66 67 getPortletPositions = function () { 68 var newPostions = []; 69 try { 70 71 $("#AccessiblityPopup select").each(function (columnIndex, value) { 72 $(value).find("option").each(function (rowIndex, value) { 73 newPostions.push( 74 { 75 "PageID": PageInfo.PageID, 76 "PortletID": $(value).attr("value"), 77 "ColumnNumber": columnIndex + 1, 78 "Order": rowIndex + 1 79 }); 80 }); 81 }); 82 } catch (error) { 83 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_GET_POSITIONS, error); 84 } 85 return newPostions; 86 }; 87 88 buildHtml = function () { 89 90 var columnHtmlItem, 91 popupContainer, 92 columnshtmlList, 93 portletPositionHTMLOption; 94 95 //private functions 96 popupContainer = 97 "<div ID=\"AccessiblityPopup\">" 98 + "<div id=\"closePopup\" class=\"modalHeadingImg\"></div>" 99 + "<span class=\"title\">" + globalizer.txT_ADMIN_PAGE_REARRANGE + "</span>" 100 + "<span class=\"title-description column" + pageLayout.columnsInfo.length+ "\">" + globalizer.txT_PAGE_CHANGE_LAYOUT_REARANGE_TITLE + "</span>" 101 + "<div class=\"Content\">" 102 + "<ul class=\"layoutColumn\">{0}</ul>" 103 + "</div>" 104 + "<div style=\"clear:both\"></div>" 105 + "<div id=\"CP_V_modalbuttons\" class=\"modalButtons\">" 106 + "<div class=\"saveButtonContainer\">" 107 + "<input type=\"submit\" value=\"" + globalizer.txT_SAVE_CHANGES + "\">" 108 + "</div>" 109 + "<div class=\"cancelButtonContainer\">" 110 + "<input type=\"submit\" value=\"" + globalizer.txT_PAGE_CHANGE_LAYOUT_CANCEL + "\">" 111 + "</div>" 112 + "</div>" 113 + "<a id=\"closePopupLink\" class=\"closeLInk\">" + globalizer.txT_PAGE_OPTIONS_CLOSE_POPUP_BUTTON + "</a>" 114 + "</div>"; 115 116 portletPositionHTMLOption = "<option value=\"{0}\">{1}</option>"; 117 118 columnHtmlItem = "<li>" 119 +"<div>" 120 + "<div class=\"optionContainer\">" 121 + "<span class=\"{0}\">" 122 + "<span class=\"icon\"></span>" 123 + "</span>" 124 + "</div>" 125 + "<label id=\"accesibilitySelectLayout{2}\" style=\"display: none;\" for=\"layoutselect{2}\">Select Layout</label>" 126 + "<select id=\"layoutselect{2}\" size=\"5\" multiple=\"multiple\">" 127 +"{1}" 128 + "</select>" 129 + "<div class=\"orderSelector\">" 130 + "<a class=\"upButton\"><span class=\"icon\"></span></a>" 131 + "<a class=\"downButton\"><span class=\"icon\"></span></a>" 132 + "</div>" 133 + "</div>" 134 + "</li>"; 135 136 columnshtmlList = []; 137 $(pageLayout.columnsInfo).each(function (i, columnInfo) { 138 //TODO: for each portlet in the column 139 // add the option in the selection container. 140 var listOption = []; 141 $(pageLayout.positions.filter(function(position) { return position.columnNumber === (i+1); })) 142 .each(function (i, e) { 143 listOption.push(window.stringUtil.format(portletPositionHTMLOption, e.portletID, e.displayName)); 144 }); 145 columnshtmlList.push(window.stringUtil.format(columnHtmlItem, columnInfo.editCssClass,$("<p>").append(listOption).html(),i+1)); 146 }); 147 148 return window.stringUtil.format(popupContainer, $("<p>").append(columnshtmlList.join('')).html()); 149 150 }; 151 var bindHandlers = function () { 152 $(".saveButtonContainer").find("input").on("click", function () { 153 var url = urlUtil.getAppRoot() + 'api/Layout'; 154 try { 155 $.ajax({
156 type: "post", 157 url: url, 158 data: { "Positions": getPortletPositions() }, 159 success: function (data) { 160 //TODO: get the positions from the response from the server, rather then making a totally new request. 161 LayoutManager.GetLayout(function () { 162 $(this).parents().find('#AccessiblityPopup').dialog("close"); 163 window.location.href = window.PageInfo.PageURL; 164 }); 165 }, 166 error: function (xhr, status, error) { 167 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_FAILED_TO_SET_POSITIONS, xhr.responseText); 168 } 169 }); 170 } catch (error) { 171 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_FAILED_TO_SET_POSITIONS, error); 172 } 173 }); 174 175 $("[class*=accessibility]").on("click", function () { 176 var optionsList = $(this).parent().parent().find("select").get(0); 177 moveAllToSelect(optionsList); 178 }); 179 180 $(".orderSelector").find(".upButton").on("click", function() { 181 moveUpItem($(this).parent().parent().find("select").get(0)); 182 }); 183 184 $(".orderSelector").find(".downButton").on("click", function() { 185 moveDownItem($(this).parent().parent().find("select").get(0)); 186 }); 187 }; 188 config = function(layoutInfo,glob) { 189 pageLayout = layoutInfo; 190 globalizer = glob; 191 }; 192 193 show = function () { 194 195 $(buildHtml()).dialog( 196 { 197 autoOpen: true, 198 resizable: false, 199 height: "auto", 200 width: "auto", 201 position: { my: 'center', at: 'center', of: window }, 202 modal: true, 203 dialogClass: 'PageOptionsPopup', 204 close: function () { 205 $(this).dialog('destroy'); 206 // if ($('#accessibilityLink')) { 207 // $('#accessibilityLink').unbind(); 208 // } 209 }, 210 open: function (data) { 211 bindHandlers(); 212 $(".cancelButtonContainer").find("input").on("click", function () { 213 $(this).parents().find('#AccessiblityPopup').dialog("close"); 214 }); 215 $(data.target).find("#closePopup").on("click", function () { 216 $(this).parents().find('#AccessiblityPopup').dialog("close"); 217 }); 218 219 $(data.target).find('.closeLInk').on("click", function () { 220 $(this).parents().find('#AccessiblityPopup').dialog("close"); 221 }); 222 } 223 }); 224 }; 225 226 // public public functions 227 return { 228 Show: show, 229 Config: config 230 }; 231 }($)); 232 233 234 LayoutManager.Error = {}; 235 LayoutManager.Error.Publish = function (message,data) { 236 $(window.stringUtil.format(LayoutManager.HTML.ErrorWrapper, message)).insertBefore("#pageTitle"); 237 // will get reported on the error console of the browser. 238 throw new Error(message + $(data)); 239 }; 240 241 // These are internal names to the Layout Manager, used to manage the Drag/Drop. 242 var listItemClassName = "rePositionItem"; 243 var listClassName = "drag-list"; 244 var dragBarClassName = "dragBar"; 245 246 /***********************************************************************/ 247 /* start private methods */ 248 /***********************************************************************/ 249 250 /** 251 * Disable all the child controls of the selector. 252 *@param {string} the selector which child controls need to be disabled. 253 */ 254 var disableAllControls = function (selector) { 255 256 try { 257 $(".pShortcut").hide(); 258 $(selector + ">.portlet-header-bar>div").hide(); 259 $(selector).addClass("drag-Content"); 260 $(selector).find('*').attr('disabled', true); 261 $(selector + ">.portlet-header-bar").addClass("drag-header"); 262 $(selector).find('a').on("click", function (e) { e.preventDefault(); }); 263 $(selector).children().filter(function () { return !$(this).hasClass("portlet-header-bar"); }).addClass("drag-disable"); 264 } catch(error) { 265 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_DISABLE_CONTROLS, error); 266 } 267 }; 268 269 var updateGlobalization = function () { 270 var url = urlUtil.getAppRoot() + 'api/Globalization/rearrange'; 271 $.ajax({
272 type: "get", 273 async:false, 274 url: url, 275 dataType: "json", 276 success: function (globalizationObject) { 277 LayoutManager.Globalization = globalizationObject; 278 }, 279 error: function (xhr, status, error) { 280 LayoutManager.Error.Publish("Failed to get the Globalization values from Server.", xhr.responseText); 281 } 282 }); 283 }; 284 /** 285 * Enable all the child controls of the selector. 286 *@param {string} the selector which child controls need to be disabled. 287 */ 288 var enableAllControls = function (selector) { 289 try { 290 $(".pShortcut").show(); 291 $(selector + ">.portlet-header-bar>div").show(); 292 $(selector).find('a').off('click'); 293 $(selector).removeClass("drag-disable"); 294 $(selector).find('*').attr('disabled', false); 295 $(selector + ">.portlet-header-bar").removeClass("drag-header"); 296 $(selector).children().filter(function () { return !$(this).hasClass("portlet-header-bar"); }).removeClass("drag-disable"); 297 } catch (error) { 298 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_ENABLE_CONTROLS, error); 299 } 300 }; 301 302 var normalizeColumns = function () { 303 try { 304 305 $("#portlet-grid").attr("class", LayoutManager.PageLayout.cssClass); 306 //TODO: get the index of the empty column that is not rendered by the server. 307 if (LayoutManager.PageLayout.emptyColumnIndexs != undefined && LayoutManager.PageLayout.emptyColumnIndexs.length > 0) { 308 $(LayoutManager.PageLayout.emptyColumnIndexs).each(function (rowIndex, value) { 309 LayoutManager.createColumnAt(value); 310 }); 311 } 312 } catch (error) { 313 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_EMPTY_COLUMN, error); 314 } 315 }; 316 317 /***********************************************************************/ 318 /* start public methods */ 319 /***********************************************************************/ 320 321 /** 322 * Get the positions for the portlets. 323 */ 324 LayoutManager.getPortletPositions = function () { 325 var newPostions = []; 326 try { 327 328 var portletIDAttribute = "portletid"; 329 330 $(LayoutManager.listContainerSelector).each(function (columnIndex, value) { 331 $(value).find(".drag-list").children("li").each(function (rowIndex, value) { 332 newPostions.push( 333 { 334 "PageID": PageInfo.PageID, 335 "PortletID": $(value).attr(portletIDAttribute), 336 "ColumnNumber": columnIndex + 1, 337 "Order": rowIndex + 1 338 }); 339 }); 340 }); 341 } catch (error) { 342 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_GET_POSITIONS, error); 343 } 344 return newPostions; 345 }; 346 347 /** 348 * Makes the given selectors draggable, by wrapping the container around. 349 * the controls of interests. 350 */ 351 LayoutManager.CreateList = function() { 352 try { 353 var listSelector = "." + listClassName; 354 var emptyClassName = "empty-List"; 355 356 //we have to set the scope of the variable in this function so that we can use them in the event handlers. 357 var draggableSelector = this.draggableSelector; 358 var portletPositions = LayoutManager.PageLayout.positions; 359 //order of call matters here, because the framework, will just change the layout 360 // if it sees empty columns. 361 // we need to normalize the layout based on the specs so that user can edit at will. 362 normalizeColumns(); 363 disableAllControls(this.draggableSelector); 364 365 //TODO: Refactor this code to a simpler method. 366 // wrap all the portlets with a list based on the available columns we have. 367 $(this.listContainerSelector).each(function (columnindex, value) { 368 369 //We are wrpping all portlets in a column with a list which we use to manage drag and drop 370 //we also need to handle the case when the column is empty. 371 if ($(this).children().length > 0) 372 $(this).children().wrapAll(window.stringUtil.format(LayoutManager.HTML.DraggableListWrapper, listClassName)); 373 else 374 $(this).append(window.stringUtil.format(LayoutManager.HTML.DraggableEmptyListWrapper, listClassName, emptyClassName)); 375 376 $(this).find(draggableSelector).each(function (rowIndex, value) { 377 378 // we are finding the meta data so that we can tell later the server the portlets that need to be updated. 379 var portletPosition = $.grep(portletPositions, function(data, key) { 380 return data.columnNumber == columnindex + 1 && data.order == rowIndex + 1; 381 }); 382 var portletID = portletPosition.length > 0 ? portletPosition[0].portletID : ""; 383 384 // we are wrapping the portlets with List Item element which will be draggable. 385 var repositioningDiv = window.stringUtil.format(LayoutManager.HTML.DraggableListItemWrapper, portletID, listItemClassName); 386 var dragMessage = window.stringUtil.format(LayoutManager.HTML.DraggableBar, dragBarClassName, LayoutManager.Globalization.msG_DRAG_DROP); 387 388 $(this).wrap(repositioningDiv); 389 $(dragMessage).insertAfter($(this).find(".portlet-header-bar"));
390 }); 391 }); 392 393 LayoutManager.WrapDraggableList(listSelector); 394 } catch (error) { 395 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_CREATE_LIST, error); 396 } 397 }; 398 399 /** 400 *Add an empty column in the document based on the current positions. 401 *@param {int} The index to insert the empty column. 402 */ 403 LayoutManager.createColumnAt = function (index) { 404 405 //TODO: find out the column number that is empty 406 // insert it before the column with the same index. If the column number is larger then the 407 // length of the selection then add it to the document. 408 var columnSelector = LayoutManager.listContainerSelector; 409 var columns = $(columnSelector); 410 var column = window.stringUtil.format(LayoutManager.HTML.ColumnWrapper, index); 411 412 413 if (index > columns.length) { 414 $(column).insertAfter(columns.last()); 415 } else { 416 $(column).insertBefore(columns.get(index-1)); 417 418 //shift the rest of the items 419 $(columnSelector + ":gt(" + (index - 1) + ")").each(function (rowIndex, value) { 420 421 var currentIndex = rowIndex + index; 422 var incrementedIndex = rowIndex + index + 1; 423 424 var currentAttributeName = "portlet-column" + currentIndex; 425 var newAttributeName = "portlet-column" + incrementedIndex; 426 427 var incrementedColumnName = value.getAttribute("class").replace(currentAttributeName, newAttributeName); 428 $(value).attr("class", incrementedColumnName); 429 }); 430 } 431 432 }; 433 434 //TODO: update this method to use a commen deff of ajax. 435 LayoutManager.GetLayout = function (successCallback) { 436 try { 437 if (LayoutManager.Globalization == undefined) { 438 updateGlobalization(); 439 } 440 var url = urlUtil.getAppRoot() + 'api/Layout'; 441 //only post for the list which is receiving the item. 442 $.ajax({
443 type: "get", 444 url: url, 445 dataType: "json", 446 data: { "pageID": PageInfo.PageID }, 447 success: function (data) { 448 LayoutManager.PageLayout = data; 449 if (successCallback != undefined) successCallback(); 450 }, 451 error: function (xhr, status, error) { 452 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_FAILED_TO_GET_POSITIONS, xhr.responseText); 453 } 454 }); 455 } catch (error) { 456 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_GET_LAYOUT, error); 457 } 458 }; 459 460 //TODO:use a common ajax method. 461 LayoutManager.UpdatePositions = function () { 462 try { 463 var url = urlUtil.getAppRoot() + 'api/Layout'; 464 $.ajax({ 465 type: "post", 466 url: url, 467 data: { "Positions": LayoutManager.getPortletPositions() }, 468 success: function (data) { 469 //TODO: get the positions from the response from the server, rather then making a totally new request. 470 LayoutManager.GetLayout(function () { 471 window.location.href = window.PageInfo.PageURL; 472 //document.location.reload(false); 473 }); 474 }, 475 error: function (xhr, status, error) { 476 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_FAILED_TO_SET_POSITIONS, xhr.responseText); 477 } 478 }); 479 } catch (error) { 480 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_FAILED_TO_SET_POSITIONS, error); 481 } 482 }; 483 484 LayoutManager.WrapDraggableList = function (listSelector) { 485 try { 486 487 var listItemSelector = "." + listItemClassName; 488 var emptyListClassName = "empty-List"; 489 490 //setup the drag and drop lists 491 $(listSelector).sortable({ 492 revert: true, 493 connectWith: listSelector, 494 placeholder: "ui-state-highlight", 495 //when done dragging see if we are on an empty list. 496 stop: function (event, ui) { 497 if ($(event.target).children(listItemSelector).length == 0) 498 $(event.target).addClass(emptyListClassName); 499 else 500 $(event.target).removeClass(emptyListClassName); 501 }, 502 //when we are dropped an item we are not empty list anymore. 503 receive: function (event, ui) { 504 $(event.target).removeClass(emptyListClassName); 505 }, 506 // when an item starts to be dragged out, check if we need are gone become empty list or not. 507 activate: function (event, ui) { 508 if ($(ui.sender).children(listItemSelector).length == 1 || $(ui.sender).children(listItemSelector).length == 0) $(ui.sender).addClass("empty-List"); 509 } 510 }).disableSelection(); 511 } catch (error) { 512 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_WRAP_PORTLETS, error); 513 } 514 }; 515 516 /** 517 * Remove the draggable item list 518 */ 519 LayoutManager.RemoveList = function () { 520 try { 521 var listSelector = "." + listClassName; 522 var listItemSelector = "." + listItemClassName; 523 var dragBarSelector = "." + dragBarClassName; 524 525 $(listItemSelector).unwrap(); 526 $(this.draggableSelector).unwrap(); 527 $(listSelector).children().filter(listSelector).children().filter(dragBarSelector).remove(); 528 enableAllControls(this.draggableSelector); 529 } catch (error) { 530 LayoutManager.Error.Publish(LayoutManager.Globalization.msG_ERROR_REMOVE_LIST, error); 531 } 532 }; 533 } ( window.LayoutManager = window.LayoutManager || {}, jQuery ));
534 535 536 537 538//TODO: refactor this to something more encapsulated. 539 $(function() { 540 541 var ShowRearrange = function () { 542 LayoutManager.draggableSelector = ".portlet"; 543 LayoutManager.listContainerSelector = ".portlet-column"; 544 $('#PageBar_pagePreferencesLink').hide(); 545 $("#PageBar_pageLayoutLink").hide(); 546 $('#PageBar_pageOpenMoxieManager').hide(); 547 $("#PageBar_pageSettingLink").hide(); 548 $("#PageBar_pageOptionsLink").hide(); 549 $("#PageBar_pageAccessLink").hide(); 550 $("#PageBar_pageRearangeLink").hide(); 551 $('#PageBar_pageOpenMoxieManager').hide(); 552 553 LayoutManager.GetLayout(function () { 554 LayoutManager.CreateList(); 555 }); 556 557 //TODO: how to use glottalization service 558 $("#PageBar_pageRearangeLink").parent().addClass("drag-menu"); 559 $(".admin-menu>.settings-menu").addClass("drag-menu"); 560 561 var dragTitle = window.stringUtil.format(LayoutManager.HTML.DraggableTitleWrapper, 562 LayoutManager.Globalization.msG_MENU_DRAG_DROP 563 + window.stringUtil.format(LayoutManager.Globalization.msG_DRAG_TITLE, 564 "<a id=\"accessibilityLink\" >", "</a>")); 565 566 var dragCancelLink = window.stringUtil.format(LayoutManager.HTML.DraggableLinkWrapper, "cancelRearange", LayoutManager.Globalization.msG_DRAG_DROP_LINK_CANEL); 567 var dragSaveLink = window.stringUtil.format(LayoutManager.HTML.DraggableButtonWrapper, "saveRearange", "btn btn-sm btn-primary save-rearrange", LayoutManager.Globalization.msG_DRAG_DROP_LINK); 568 569 $(dragCancelLink).insertAfter($("#PageBar_pageRearangeLink")); 570 $(dragSaveLink).insertAfter($("#PageBar_pageRearangeLink")); 571 $(dragTitle).insertAfter($("#PageBar_pageRearangeLink")); 572 573 $("#saveRearange").on("click", function () { 574 CloseRearrange($("#PageBar_pageRearangeLink")); 575 }); 576 577 $("#accessibilityLink").on("click", function () { 578 window.LayoutManager.AccesibilityPopup.Config(window.LayoutManager.PageLayout, LayoutManager.Globalization); 579 window.LayoutManager.AccesibilityPopup.Show(); 580 }); 581 $("#cancelRearange").on("click", function () { 582 window.location.href = window.PageInfo.PageURL; 583 }); 584 clicked = true; 585 }; 586 var CloseRearrange = function (object) { 587 588 LayoutManager.UpdatePositions(); 589 LayoutManager.RemoveList(); 590 $('#PageBar_pagePreferencesLink').show(); 591 $("#PageBar_pageLayoutLink").show(); 592 $('#PageBar_pageOpenMoxieManager').show(); 593 $("#PageBar_pageOptionsLink").show(); 594 $("#PageBar_pageSettingLink").show(); 595 $("#PageBar_pageAccessLink").show(); 596 $('#PageBar_pageOpenMoxieManager').show(); 597 $("#cancelRearange").remove(); 598 $("#saveRearange").remove(); 599 $("#drag-title").remove(); 600 601 object.parent().removeClass("drag-menu"); 602 object.text(LayoutManager.Globalization.msG_DRAG_DROP_LINK_NORMAL); 603 clicked = false; 604 }; 605 var getParameterByName = function(name) { 606 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 607 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 608 results = regex.exec(location.search); 609 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 610 }; 611 612 //TODO: check the page info object for the status 613 // then if it is customizing then add a link 614 if (typeof window.PageInfo !== 'undefined' && (typeof window.PageInfo !== 'undefined' && (getParameterByName("Rearrange") == "" || window.PageInfo.IsCustomizing == "True" || window.PageInfo.IsShowingPortlet == "True"))) { 615 616 $("#PageBar_pageRearangeLink").off(); 617 $("#PageBar_pageRearangeLink").attr("href", window.PageInfo.PageURL + "?Rearrange=true"); 618 $("a.changeLayout").attr("href", window.PageInfo.PageURL + "?tool=custpage&pageAdminScreen=pagelayout"); 619 $("a.rearrangePages").attr("href", window.PageInfo.PageURL + "?Rearrange=true"); 620 621 } else { 622 var clicked = false; 623 if (getParameterByName("Rearrange") == "true") { 624 ShowRearrange(); 625 $("#adminSubMenu").addClass("in"); 626 $('span.wrench-toggle-arrow').toggleClass('glyphicons-chevron-down glyphicons-chevron-up'); 627 } 628 $("#PageBar_pageRearangeLink").on("click", function () { 629 var rearrange = $(this); 630 if (clicked) { CloseRearrange($(this)); } 631 else {ShowRearrange();} 632 }); 633 } 634 });
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.