Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 5:19 PM

in-portal

Index: branches/5.0.x/core/admin_templates/js/jquery/thickbox/thickbox.js
===================================================================
--- branches/5.0.x/core/admin_templates/js/jquery/thickbox/thickbox.js (revision 13372)
+++ branches/5.0.x/core/admin_templates/js/jquery/thickbox/thickbox.js (revision 13373)
@@ -1,733 +1,742 @@
/*
* Thickbox 3.1 - One Box To Rule Them All.
* By Cody Lindley (http://www.codylindley.com)
* Copyright (c) 2007 cody lindley
* Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
// on page load call TB.init
$(document).ready(
function() {
// pass where to apply thickbox
TB.init('a.thickbox, area.thickbox, input.thickbox');
// preload image
TB.imgLoader = new Image();
TB.imgLoader.src = TB.pathToImage;
}
);
function TB () {}
TB.pathToImage = 'images/loadingAnimation.gif';
TB.Width = null;
TB.Height = null;
TB.lastParams = {};
TB.windows = new Array();
TB.windowMetaData = new Array ();
TB.useStack = true;
TB.closeHtml = '<img src="img/close_window15.gif" width="15" height="15" alt="close"/><br/>'; // 'close';
TB.lastOverflow = '';
//add thickbox to href & area elements that have a class of .thickbox
TB.init = function (domChunk) {
$(domChunk).click(
function() {
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
TB.show( {caption: t, url: a, imageGroup: g} );
this.blur();
return false;
}
);
}
TB.getId = function ($id, $diff) {
var $length = TB.windows.length;
if ($diff !== undefined) {
$length += $diff;
}
if ($length == 0) {
return $id;
}
return $id + $length;
}
// function called when the user clicks on a thickbox link
TB.show = function (params) {
TB.lastParams = params;
// caption, url, imageGroup, onDataReceived, onAfterShow, postParams
+
+ if (TB.imgLoader === undefined) {
+ // loader image is set from $(document).ready(...) and when some slow javascript
+ // makes page busy and user clicks on something, that opens window, then there will
+ // be an error
+
+ return ;
+ }
+
try {
if (TB.useStack) {
// increment window counter
if (TB.windows.length == 0) {
getFrame('head').$FrameResizer.fullScreen();
$(window).scroll(TB.position);
TB.lastOverflow = document.body.style.overflow;
document.body.style.overflow = 'hidden';
}
TB.windows[TB.windows.length] = '#' + TB.getId('TB_window', 1);
TB.windowMetaData[TB.windowMetaData.length] = {};
}
if (typeof document.body.style.maxHeight === 'undefined') {
// if IE6 browser only
$('body', 'html').css( {height: '100%', width: '100%'} );
$('html').css('overflow', 'hidden');
if ($('#TB_overlay').length == 0) {
// create overlay
$('body').append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div>");
$('#TB_overlay').click(TB.remove);
}
if (document.getElementById( TB.getId('TB_window') ) === null) {
// iframe to hide select elements in ie6
$('body').append("<div id='" + TB.getId('TB_window') + "' class='TB_window'></div>");
}
} else {
// all other browsers
if ($('#TB_overlay').length == 0) {
// create overlay
$('body').append("<div id='TB_overlay'></div>");
$('#TB_overlay').click(TB.remove);
}
if ( $('#' + TB.getId('TB_window') ).length == 0) {
$('body').append("<div id='" + TB.getId('TB_window') + "' class='TB_window'></div>");
}
}
if (TB.detectMacXFF()) {
$('#TB_overlay').addClass('TB_overlayMacFFBGHack'); // use png overlay so hide flash
} else {
$('#TB_overlay').addClass('TB_overlayBG'); // use background and opacity
}
if (params.caption === null) {
params.caption = '';
}
$('body').append("<div id='TB_load'><img src='" + TB.imgLoader.src + "' /></div>"); // add loader to the page
$('#TB_load').show(); // show loader
var baseURL;
if (params.url.indexOf('?') !== -1) {
// ff there is a query string involved
baseURL = params.url.substr(0, params.url.indexOf('?'));
} else {
baseURL = params.url;
}
var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
var url_params = {};
if ( baseURL.toLowerCase().match(urlString) ) {
TB.processImages(params, urlString);
} else {
var queryString = params.url.replace(/^[^\?]+\??/,'');
url_params = TB.parseQuery(queryString);
TB.processDialog(params, url_params);
}
if (url_params['modal'] != 'true') {
$(document).bind(
'keyup',
function(e){
if (e.which == 27){
// close
TB.remove();
}
}
);
}
} catch(e) {
//nothing here
alert("An exception occurred in the script.\nError name: " + e.name + ".\nError message: " + e.message);
}
}
// helper functions below
TB.processImages = function (params, urlString) {
// code to show images
var TB_PrevCaption = '';
var TB_PrevURL = '';
var TB_PrevHTML = '';
var TB_NextCaption = '';
var TB_NextURL = '';
var TB_NextHTML = '';
var TB_imageCount = '';
var TB_FoundURL = false;
if (params.imageGroup) {
// scan images in group to create Prev/Next links
var TB_TempArray = $('a[rel=' + params.imageGroup + ']').get();
for (var TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === '')); TB_Counter++) {
var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
if (!(TB_TempArray[TB_Counter].href == params.url)) {
if (TB_FoundURL) {
TB_NextCaption = TB_TempArray[TB_Counter].title;
TB_NextURL = TB_TempArray[TB_Counter].href;
TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
} else {
TB_PrevCaption = TB_TempArray[TB_Counter].title;
TB_PrevURL = TB_TempArray[TB_Counter].href;
TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
}
} else {
TB_FoundURL = true;
TB_imageCount = 'Image ' + (TB_Counter + 1) + ' of ' + TB_TempArray.length;
}
}
}
var imgPreloader = new Image();
$(imgPreloader).bind(
'load',
function() {
$(this).unbind('load');
var $image_size = TB.scaleImage.call(TB, this);
TB.Width = $image_size.width + 30;
TB.Height = $image_size.height + 60;
$('#' + TB.getId('TB_window')).append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='" + params.url + "' width='" + $image_size.width + "' height='" + $image_size.height + "' alt='" + params.caption + "'/></a>" + "<div id='" + TB.getId('TB_caption') + "'>" + params.caption + "<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='" + TB.getId('TB_closeWindow') + "'><a href='#' id='" + TB.getId('TB_closeWindowButton') + "' title='Close'>close</a> or Esc Key</div>");
$('#' + TB.getId('TB_closeWindowButton')).click(TB.remove);
if (TB_PrevHTML !== '') {
function goPrev() {
$('#' + TB.getId('TB_window')).remove();
$('body').append("<div id='" + TB.getId('TB_window') + "' class='TB_window'></div>");
TB.show( {caption: TB_PrevCaption, url: TB_PrevURL, imageGroup: params.imageGroup} );
return false;
}
$('#TB_prev').click(goPrev);
}
if (TB_NextHTML !== '') {
function goNext() {
$('#' + TB.getId('TB_window')).remove();
$('body').append("<div id='" + TB.getId('TB_window') + "' class='TB_window'></div>");
TB.show( {caption: TB_NextCaption, url: TB_NextURL, imageGroup: params.imageGroup} );
return false;
}
$('#TB_next').click(goNext);
}
$(document).bind(
'keydown',
function(e) {
var keycode = e.which;
if (keycode == 27) { // close
TB.remove();
} else if (keycode == 190) {
// display previous image
if (TB_NextHTML != '') {
$(this).unbind('keydown');
goNext();
}
} else if (keycode == 188) {
// display next image
if(TB_PrevHTML != ''){
$(this).unbind('keydown');
goPrev();
}
}
}
);
// show image after it's loaded
TB.position();
$('#TB_load').remove();
$('#TB_ImageOff').click(TB.remove);
$('#' + TB.getId('TB_window')).css('display', 'block'); // for safari using css instead of show
}
);
imgPreloader.src = params.url;
}
TB.scaleImage = function ($image) {
// resizing large images - orginal by Christian Montoya edited by me
var pagesize = TB.getPageSize();
var x = pagesize[0] - 150;
var y = pagesize[1] - 150;
var imageWidth = $image.width;
var imageHeight = $image.height;
if ($image.src !== undefined) {
if (imageWidth > x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight > y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
} else if (imageHeight > y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth > x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}
}
else {
if (imageWidth > x) {
imageWidth = x;
}
if (imageHeight > y) {
imageHeight = y;
}
}
return {width: imageWidth, height: imageHeight};
}
TB.processDialog = function (params, url_params) {
// code to show html
// window size is global
var $fake_image = {
width: (url_params['width'] * 1) || 600, // defaults to 630 if no paramaters were added to URL
height: (url_params['height'] * 1) || 400 // defaults to 440 if no paramaters were added to URL
}
var $image_size = TB.scaleImage.call(TB, $fake_image);
TB.setWindowMetaData('window_size', $image_size);
TB.setWindowMetaData('window_maximized', false);
TB.Width = $image_size.width + 30;
TB.Height = $image_size.height + 40;
var ajaxContentW = TB.Width - 30;
var ajaxContentH = TB.Height - 45;
var $modal = url_params['modal'] == 'true';
if (params.url.indexOf('TB_iframe') != -1) {
// either iframe or ajax window
urlNoQuery = params.url.split('TB_');
$('#' + TB.getId('TB_iframeContent')).remove();
if ($modal) {
// iframe modal -> don't close when clicking on grayed-out area
$('#TB_overlay').unbind();
}
var $caption_html = "<div id='" + TB.getId('TB_title') + "' class='TB_title'><div id='" + TB.getId('TB_ajaxWindowTitle') + "' class='TB_ajaxWindowTitle'>" + params.caption + "</div><div id='" + TB.getId('TB_closeAjaxWindow') + "' class='TB_closeAjaxWindow'><a href='#' id='" + TB.getId('TB_closeWindowButton') + "' class='TB_closeWindowButton' title='Close'>" + TB.closeHtml + "</a>" + ($modal ? '' : ' or Esc Key') + "</div></div>";
$('#' + TB.getId('TB_window')).append($caption_html + "<iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='" + TB.getId('TB_iframeContent') + "' name='" + TB.getId('TB_iframeContent' + Math.round(Math.random() * 1000)) + "' onload='TB.showIframe()' class='TB_iframeContent' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;'> </iframe>");
} else {
// not an iframe, ajax
if ($('#' + TB.getId('TB_window')).css('display') != 'block') {
var $caption_html = "<div id='" + TB.getId('TB_title') + "' class='TB_title'><div id='" + TB.getId('TB_ajaxWindowTitle') + "' class='TB_ajaxWindowTitle'>" + params.caption + "</div><div id='" + TB.getId('TB_closeAjaxWindow') + "' class='TB_closeAjaxWindow'><a href='#' id='" + TB.getId('TB_closeWindowButton') + "' class='TB_closeWindowButton'>" + TB.closeHtml + "</a>" + ($modal ? '' : ' or Esc Key') + "</div></div>";
if (!$modal) {
// ajax no modal
$('#' + TB.getId('TB_window')).append($caption_html + "<div id='" + TB.getId('TB_ajaxContent') + "' class='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'></div>");
} else {
// ajax modal
$('#TB_overlay').unbind();
$('#' + TB.getId('TB_window')).append($caption_html + "<div id='" + TB.getId('TB_ajaxContent') + "' class='TB_modal TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>");
}
} else {
// this means the window is already up, we are just loading new content via ajax
var $ajax_content = $('#' + TB.getId('TB_ajaxContent')).get(0);
$ajax_content.style.width = ajaxContentW + 'px';
$ajax_content.style.height = ajaxContentH + 'px';
$ajax_content.scrollTop = 0;
$('#' + TB.getId('TB_ajaxWindowTitle')).html(params.caption);
}
}
$('#' + TB.getId('TB_closeWindowButton')).click(TB.remove);
if (params.url.indexOf('TB_inline') != -1) {
$('#' + TB.getId('TB_ajaxContent')).html( $('#' + url_params['inlineId']).html() );
$('#' + TB.getId('TB_window')).unload(
function () {
// move elements back when you're finished
$('#' + url_params['inlineId']).html( $('#' + TB.getId('TB_ajaxContent')).html() );
}
);
TB.position();
$('#TB_load').remove();
$('#' + TB.getId('TB_window')).css('display', 'block');
} else if (params.url.indexOf('TB_iframe') != -1) {
TB.position();
if ($.browser.safari) {
// safari needs help because it will not fire iframe onload
$('#TB_load').remove();
$('#' + TB.getId('TB_window')).css('display', 'block');
}
} else {
$.ajaxSetup({cache: false});
var $content_url = params.url;
if (params.postParams === undefined) {
$.get(
$content_url,
function ($data) {
TB.onDataReceived($data, params);
}
);
}
else {
$.post(
$content_url,
params.postParams,
function ($data) {
TB.onDataReceived($data, params);
}
);
}
}
TB.updateZIndex(); // update z-index on window open
}
TB.setWindowTitle = function ($title) {
if (TB.useStack) {
// remember window titles
if (TB.windowMetaData.length == 0) {
// remember title of topmost window too
TB.windowMetaData[TB.windowMetaData.length] = {window_name: 'main'};
}
TB.setWindowMetaData('title', $title);
}
$('#' + TB.getId('TB_ajaxWindowTitle') ).html($title);
}
TB.parseRedirect = function ($data) {
var $match_redirect = new RegExp('^#redirect#(.*)').exec($data);
if ($match_redirect != null) {
// redirect to external template requested
return $match_redirect[1];
}
return false;
}
TB.onDataReceived = function ($data, $params) {
if ( $.isFunction($params.onDataReceived) ) {
$data = $params.onDataReceived($data);
if ($data === false) {
// this callback even could prevent redirect action
// callback requested to stop processing
return ;
}
}
var $redirect = TB.parseRedirect($data);
if ($redirect !== false) {
window.location.href = $redirect;
return ;
}
$('#' + TB.getId('TB_ajaxContent')).html($data);
TB.position();
$('#TB_load').remove();
TB.init('#' + TB.getId('TB_ajaxContent') + ' a.thickbox');
$('#' + TB.getId('TB_window')).css('display', 'block');
if ( $.isFunction($params.onAfterShow) ) {
$params.onAfterShow();
}
}
TB.showIframe = function () {
$('#TB_load').remove();
$('#' + TB.getId('TB_window')).css('display', 'block');
try {
if ( $.isFunction(TB.lastParams.onAfterShow) ) {
TB.lastParams.onAfterShow();
}
}
catch (e) {
// IE gives "Can't execute code from a freed script" when iframe is closed and parent window is reloaded
// It's not a big problem, that our method is not called in this case, becase it doesn't do anything in
// such case either
}
}
TB.remove = function ($e, $on_close) {
var $last_window = TB.useStack && TB.windows.length <= 1;
$('#TB_imageOff').unbind('click');
$('#' + TB.getId('TB_closeWindowButton')).unbind('click');
/*$('#' + TB.getId('TB_window')).fadeOut(
'fast',
function() {
TB.onAfterFade($last_window);
}
)*/
$('#' + TB.getId('TB_window')).hide();
TB.onAfterFade($last_window, $on_close);
if ($last_window) {
$('#TB_load').remove();
if (typeof document.body.style.maxHeight == 'undefined') {
// if IE 6
$('body','html').css( {height: 'auto', width: 'auto'} );
$('html').css('overflow', '');
}
$(document).unbind('keydown').unbind('keyup');
document.body.style.overflow = TB.lastOverflow;
}
return false;
}
TB.onAfterFade = function ($last_window, $on_close) {
if ($last_window) {
// hide overlays first
$('#TB_overlay,#TB_HideSelect').remove();
}
if ($.isFunction($on_close)) {
// use close callback, because iframe will be removed later in this method
$on_close();
}
$('#' + TB.getId('TB_window')).unload().remove();
if (TB.useStack) {
// tricky window removing to prevent memory leaks
var n_nesting = TB.windows.length - 1;
$(TB.windows[n_nesting]).remove();
TB.windows[n_nesting] = null;
TB.windows.length = n_nesting;
// window meta data has one more record at beginning for topmost window
TB.windowMetaData[n_nesting + 1] = null;
TB.windowMetaData.length = n_nesting + 1;
TB.updateZIndex(); // update z-index on window close
set_window_title(TB.windowMetaData[TB.windowMetaData.length - 1].title);
if (TB.windows.length == 0) {
getFrame('head').$FrameResizer.fullScreen(true);
}
}
}
TB.position = function () {
var pagesize = TB.getPageSize();
var $window = $('#' + TB.getId('TB_window'));
var $borders = {
horizontal: $window.outerWidth() - $window.width(),
vertical: $window.outerHeight() - $window.height()
};
var $top = $(window).scrollTop() + Math.round((pagesize[1] - TB.Height - $borders.vertical) / 2);
var $left = Math.round((pagesize[0] - TB.Width - $borders.horizontal) / 2);
$window.css(
{
width: TB.Width + 'px',
height: TB.Height + 'px'
}
);
if ($left > 0) {
// when something large is opened from right, then we got negative left
// (negative values breaks down "draggable.containment")
$window.css('left', $left + 'px');
}
if ($top > 0) {
// when Firebug console is opened from bottom, then we got negative top
// (negative values breaks down "draggable.containment")
$window.css('top', $top + 'px');
}
$window
.resizable(
{
alsoResize: '#' + TB.getId('TB_iframeContent'),
stop: function(event, ui) {
if (TB.getWindowMetaData('window_maximized')) {
return ;
}
var $window = $(this);
var $window_size = {
width: $window.width() - 30,
height: $window.height() - 40
}
TB.setWindowMetaData('window_size', $window_size);
}
}
)
.draggable(
{
handle: '.TB_title',
containment: 'window'
}
);
$('#' + TB.getId('TB_title')).dblclick(
function($e) {
var $window = $('#' + TB.getId('TB_window'));
var $maximized = TB.getWindowMetaData('window_maximized');
var $borders = {
horizontal: $window.outerWidth() - $window.width(),
vertical: $window.outerHeight() - $window.height()
};
if ($maximized) {
var $window_size = TB.getWindowMetaData('window_size');
var $new_width = $window_size.width + 30;
var $new_height = $window_size.height + 40;
TB.setWindowMetaData('window_maximized', false);
}
else {
var $new_width = pagesize[0] - $borders.horizontal;
var $new_height = pagesize[1] - $borders.vertical;
TB.setWindowMetaData('window_maximized', true);
}
var $window_width = $window.width();
var $window_height = $window.height();
$window.css(
{
width: $new_width + 'px',
height: $new_height + 'px',
left: Math.round((pagesize[0] - $new_width - $borders.horizontal) / 2) + 'px',
top: $(window).scrollTop() + Math.round((pagesize[1] - $new_height - $borders.vertical) / 2) + 'px'
}
);
var $width_diff = $new_width - $window_width;
var $height_diff = $new_height - $window_height;
var $iframe = $('#' + TB.getId('TB_iframeContent'));
$iframe.width( $iframe.width() + $width_diff );
$iframe.height( $iframe.height() + $height_diff );
}
);
/*$('#' + TB.getId('TB_window')).css( {marginLeft: '-' + parseInt((TB.Width / 2), 10) + 'px', width: TB.Width + 'px'} );
if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) {
// take away IE6
$('#' + TB.getId('TB_window')).css( {marginTop: '-' + parseInt((TB.Height / 2), 10) + 'px'} );
}*/
}
TB.parseQuery = function (query) {
var Params = {};
if (!query) {
// return empty object
return Params;
}
var Pairs = query.split(/[;&]/);
for (var i = 0; i < Pairs.length; i++ ) {
var KeyVal = Pairs[i].split('=');
if (!KeyVal || KeyVal.length != 2) {
continue;
}
var key = unescape( KeyVal[0] );
var val = unescape( KeyVal[1] );
val = val.replace(/\+/g, ' ');
Params[key] = val;
}
return Params;
}
TB.getPageSize = function () {
var de = document.documentElement;
var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
return [w, h];
}
TB.detectMacXFF = function () {
var userAgent = navigator.userAgent.toLowerCase();
return userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox') != -1;
}
TB.updateZIndex = function () {
// #TB_overlay - 100
// .TB_window - 102 [ok]
// #TB_load - 103 [ok]
// #TB_HideSelect - 99
var n_nesting = TB.windows.length - 1;
var $window_index = 102 + n_nesting + TB.windows.length;
// alert('nesting ' + n_nesting + ', window index ' + $window_index);
$(TB.windows[n_nesting]).css('z-index', $window_index); // window position is dependend on it's opening order
$('#TB_load').css('z-index', $window_index + 1); // progress bar is over window
$('#TB_overlay').css('z-index', $window_index - 1); // overlay is under window
}
TB.setWindowMetaData = function ($title, $value) {
TB.windowMetaData[TB.windowMetaData.length - 1][$title] = $value;
}
TB.getWindowMetaData = function ($title) {
return TB.windowMetaData[TB.windowMetaData.length - 1][$title];
}
TB.findWindow = function ($name, $diff) {
if (!isset($diff)) {
$diff = 0;
}
for (var $i = TB.windowMetaData.length - 1; $i >= 0; $i--) {
// alert('comparing [' + TB.windowMetaData[$i].window_name + '] to [' + $name + ']');
if (TB.windowMetaData[$i].window_name == $name) {
break;
}
}
var $window_index = $i + $diff;
if ($i == 0 || $window_index <= 0) {
// not found or "main" window was requested -> it's not in TB.windows array anyway
return window;
}
return $found_window = $('.TB_iframeContent', TB.windows[$window_index - 1]).get(0).contentWindow;
}
\ No newline at end of file
Index: branches/5.0.x/core/admin_templates/js/grid.js
===================================================================
--- branches/5.0.x/core/admin_templates/js/grid.js (revision 13372)
+++ branches/5.0.x/core/admin_templates/js/grid.js (revision 13373)
@@ -1,550 +1,547 @@
var $GridManager = new GridManager();
function GridManager () {
this.Grids = Grids; // get all from global variable, in future replace all references to it with $GridManager.Grids
this.AlternativeGrids = new Array();
}
GridManager.prototype.AddAlternativeGrid = function ($source_grid, $destination_grid, $reciprocal)
{
if ($source_grid == $destination_grid) {
return false;
}
if (typeof(this.AlternativeGrids[$source_grid]) == 'undefined') {
// alternative grids not found, create empty list
this.AlternativeGrids[$source_grid] = new Array();
}
if (!in_array($destination_grid, this.AlternativeGrids[$source_grid])) {
// alternative grids found, check if not added already
this.AlternativeGrids[$source_grid].push($destination_grid);
}
if ($reciprocal) {
this.AddAlternativeGrid($destination_grid, $source_grid);
}
}
GridManager.prototype.ClearAlternativeGridsSelection = function ($source_prefix)
{
if (!this.AlternativeGrids[$source_prefix]) return false;
var $i = 0;
var $destination_prefix = '';
while ($i < this.AlternativeGrids[$source_prefix].length) {
$destination_prefix = this.AlternativeGrids[$source_prefix][$i];
if (this.Grids[$destination_prefix]) {
// alternative grid set, but not yet loaded by ajax
this.Grids[$destination_prefix].ClearSelection();
}
$i++;
}
}
GridManager.prototype.CheckDependencies = function ($prefix) {
if (typeof(this.Grids[$prefix]) != 'undefined') {
this.Grids[$prefix].CheckDependencies('GridManager.CheckDependencies');
}
}
function GridItem(grid, an_element, cb, item_id, class_on, class_off)
{
this.Grid = grid;
this.selected = false;
this.id = an_element.id;
this.ItemId = item_id;
this.sequence = parseInt(an_element.getAttribute('sequence'));
// this.class_on = class_on;
if (class_off == ':original') {
this.class_off = an_element.className;
}
else
this.class_off = class_off;
if (class_on.match(/(.*):(.*)/)) {
var even = RegExp.$2;
var odd = RegExp.$1;
this.class_on = this.class_off.match(/even/) ? even : odd
}
else {
this.class_on = class_on
}
this.HTMLelement = an_element;
if (document.getElementById('left_'+an_element.id)) {
this.LeftElement = document.getElementById('left_'+an_element.id);
}
else {
this.LeftElement = false;
}
this.CheckBox = cb;
this.value = this.ItemId;
this.ItemType = 11;
}
GridItem.prototype.Init = function ()
{
this.HTMLelement.GridItem = this;
this.HTMLelement.onclick = function(ev) {
this.GridItem.Click(ev);
};
this.HTMLelement.ondblclick = function(ev) {
this.GridItem.DblClick(ev);
}
if ( this.LeftElement ) {
this.LeftElement.GridItem = this;
this.LeftElement.onclick = function(ev) {
this.GridItem.Click(ev);
};
this.LeftElement.ondblclick = function(ev) {
this.GridItem.DblClick(ev);
}
}
if ( isset(this.CheckBox) ) {
this.CheckBox.GridItem = this;
this.CheckBox.onclick = function(ev) {
this.GridItem.cbClick(ev);
};
this.CheckBox.ondblclick = function(ev) {
this.GridItem.DblClick(ev);
}
}
// if ( this.Grid.MouseOverClass ) {
addEvent(this.HTMLelement, 'mouseover', function(ev) { this.GridItem.MouseOver(ev)}, true); // true for traditional event model
addEvent(this.HTMLelement, 'mouseout', function(ev) { this.GridItem.MouseOut(ev)}, true);
if ( this.LeftElement ) {
addEvent(this.LeftElement, 'mouseover', function(ev) { this.GridItem.MouseOver(ev)}, true);
addEvent(this.LeftElement, 'mouseout', function(ev) { this.GridItem.MouseOut(ev)}, true);
}
// }
}
GridItem.prototype.AddClass = function(elem, class_name)
{
var cur_classes = elem.className;
// if (cur_classes.match(class_name)) return;
elem.className = cur_classes+' '+class_name;
// console.log('added %s to %s resulted %s', class_name, elem.id, elem.className)
}
GridItem.prototype.RemoveClass = function(elem, class_name)
{
var cur_classes = elem.className;
// console.log('looking for %s in %s', class_name, cur_classes)
if (!cur_classes.match(class_name)) return;
cur_classes = cur_classes.replace(class_name, '');
cur_classes = cur_classes.replace(/[ ]+/, ' ');
elem.className = cur_classes;
// console.log('removed %s from %s resulted %s', class_name, elem.id, elem.className)
}
GridItem.prototype.DisableClicking = function ()
{
this.HTMLelement.onclick = function(ev) {
return false;
};
this.HTMLelement.ondblclick = function(ev) {
return false;
}
if ( this.LeftElement ) {
this.LeftElement.onclick = function(ev) {
return false;
};
this.LeftElement.ondblclick = function(ev) {
return false;
}
}
if ( isset(this.CheckBox) ) {
this.CheckBox.onclick = function(ev) {
return false;
};
}
}
GridItem.prototype.Select = function ()
{
if (this.selected) return;
this.selected = true;
this.HTMLelement.setAttribute('_row_selected', 1)
this.AddClass(this.HTMLelement, this.class_on);
if ( this.LeftElement ) {
this.LeftElement.setAttribute('_row_selected', 1)
this.AddClass(this.LeftElement, this.class_on);
}
if ( isset(this.CheckBox) ) {
this.CheckBox.checked = true;
}
this.Grid.LastSelectedId = this.ItemId;
this.Grid.SelectedCount++;
// this is for in-portal only (used in relation select)
LastCheckedItem = this;
if (typeof (this.Grid.OnSelect) == 'function' ) {
this.Grid.OnSelect(this.ItemId);
}
}
GridItem.prototype.UnSelect = function ( force )
{
if ( !this.selected && !force) return;
this.selected = false;
this.HTMLelement.removeAttribute('_row_selected')
this.RemoveClass(this.HTMLelement, this.class_on);
if ( this.LeftElement ) {
this.LeftElement.removeAttribute('_row_selected')
this.RemoveClass(this.LeftElement, this.class_on);
}
if ( isset(this.CheckBox) ) {
this.CheckBox.checked = false;
}
this.Grid.SelectedCount--;
if (typeof (this.Grid.OnUnSelect) == 'function' ) {
this.Grid.OnUnSelect(this.ItemId);
}
this.Grid.LastSelectedId = null;
}
GridItem.prototype.ClearBrowserSelection = function() {
ClearBrowserSelection();
}
GridItem.prototype.Click = function (ev)
{
//this.ClearBrowserSelection();
this.Grid.ClearAlternativeGridsSelection('GridItem.Click');
var e = !is.ie ? ev : window.event;
if (e.shiftKey && !this.Grid.RadioMode) {
this.ClearBrowserSelection();
this.Grid.SelectRangeUpTo(this.sequence);
}
else {
if (e.ctrlKey && !this.Grid.RadioMode) {
this.Toggle()
}
else {
if (!(this.Grid.RadioMode && this.Grid.LastSelectedId == this.ItemId && this.selected)) {
// don't clear selection if item same as current is selected
if (!this.Grid.StickySelection) {
this.Grid.ClearSelection(null,'GridItem.Click');
}
else {
if (this.Grid.LastSelectedId == this.ItemId) {
return;
}
}
this.Toggle();
}
}
}
this.Grid.CheckDependencies('GridItem.Click');
e.cancelBubble = true;
}
GridItem.prototype.cbClick = function (ev)
{
var e = is.ie ? window.event : ev;
if (this.Grid.RadioMode) this.Grid.ClearSelection(null,'GridItem.cbClick');
this.Grid.ClearAlternativeGridsSelection('GridItem.cbClick');
this.Toggle();
this.Grid.CheckDependencies('GridItem.cbClick');
e.cancelBubble = true;
}
GridItem.prototype.DblClick = function (ev)
{
var e = is.ie ? window.event : ev;
this.Grid.Edit();
}
GridItem.prototype.MouseOver = function (ev)
{
this.HTMLelement.setAttribute('_row_highlighted', 1)
this.AddClass(this.HTMLelement, this.Grid.MouseOverClass);
// if (this.Grid.MouseOverClass) {this.HTMLelement.className = this.Grid.MouseOverClass;}
if ( this.LeftElement ) {
this.LeftElement.setAttribute('_row_highlighted', 1)
// if (this.Grid.MouseOverClass) this.LeftElement.className = this.Grid.MouseOverClass;
this.AddClass(this.LeftElement, this.Grid.MouseOverClass);
// this.LeftElement.className = this.LeftElement.className; // this is to make IE re-render the element
}
}
GridItem.prototype.MouseOut = function (ev)
{
this.HTMLelement.removeAttribute('_row_highlighted')
this.RemoveClass(this.HTMLelement, this.Grid.MouseOverClass);
// if (this.Grid.MouseOverClass) {this.HTMLelement.className = this.selected ? this.class_on : this.class_off;}
if ( this.LeftElement ) {
this.LeftElement.removeAttribute('_row_highlighted')
this.RemoveClass(this.LeftElement, this.Grid.MouseOverClass);
// if (this.Grid.MouseOverClass) this.LeftElement.className = this.selected ? this.class_on : this.class_off;
// this.LeftElement.className = this.LeftElement.className; // this is to make IE re-render the element
}
}
GridItem.prototype.Toggle = function ()
{
if (this.selected) this.UnSelect()
else {
this.Grid.LastSelectedSequence = this.sequence;
this.Select();
}
}
GridItem.prototype.FallsInRange = function (from, to)
{
return (from <= to) ?
(this.sequence >= from && this.sequence <= to) :
(this.sequence >= to && this.sequence <= from);
}
function Grid(prefix, class_on, class_off, dbl_click, toolbar)
{
this.prefix = prefix;
this.class_on = class_on;
this.class_off = class_off;
this.Items = {};
this.LastSelectedSequence = 1;
this.LastSelectedId = null;
this.DblClick = dbl_click;
this.ToolBar = toolbar;
this.SelectedCount = 0;
this.AlternativeGrids = new Array();
this.DependantButtons = new Array();
this.RadioMode = false;
this.MouseOverClass = false;
// K3-style sticky selection, selection an item does not unselect currently selected
// even w/o Ctrl key pressed
this.StickySelection = false;
}
Grid.prototype.EnableRadioMode = function() {
this.RadioMode = true;
this.StickySelection = false;
}
Grid.prototype.AddItem = function( an_item ) {
this.Items[an_item.id] = an_item;
}
Grid.prototype.AddItemsByIdMask = function ( tag, mask, cb_mask ) {
var $item_id=0;
elements = document.getElementsByTagName(tag.toUpperCase());
for (var i=0; i < elements.length; i++) {
if ( typeof(elements[i].id) == 'undefined') {
continue;
}
if ( !elements[i].id.match(mask)) continue;
$item_id=RegExp.$1;
cb_name = cb_mask.replace('$$ID$$',$item_id);
cb = document.getElementById(cb_name);
if (typeof(cb) == 'undefined') alert ('No Checkbox defined for item '+elements[i].id);
this.AddItem( new GridItem( this, elements[i], cb, $item_id, this.class_on, this.class_off ) );
}
}
Grid.prototype.InitItems = function() {
for (var i in this.Items) {
this.Items[i].Init();
}
this.ClearSelection( true,'Grid.InitItems' );
var a_Grid = this;
addEvent(document, 'keyup', function(ev) {
var e = !is.ie ? ev : window.event;
switch (e.keyCode) {
case 65:
if (!e.ctrlKey) break;
a_Grid.SelectAll();
ClearBrowserSelection()
// window.setTimeout(ClearBrowserSelection, 500);
break;
case 27:
a_Grid.ClearSelection();
break;
case 33:
case 37:
//alert('<-') // go to prev page here
break;
case 34:
case 39:
// alert('->') // go to next page here
break;
case 88:
ClearBrowserSelection();
break;
}
});
}
Grid.prototype.DisableClicking = function() {
for (var i in this.Items) {
this.Items[i].DisableClicking();
}
this.ClearSelection( true, 'Grid.DisableClicking' );
}
Grid.prototype.ClearSelection = function( force, called_from ) {
// alert('selection clear. force: '+force+'; called_from: '+called_from);
if (typeof(force) == 'undefined') force = false;
if (this.CountSelected() == 0 && !force) return;
for (var i in this.Items) {
this.Items[i].UnSelect(force);
}
this.SelectedCount = 0;
this.CheckDependencies('Grid.ClearSelection');
}
Grid.prototype.GetSelected = function() {
var $ret = new Array();
for (var i in this.Items) {
if (this.Items[i].selected) {
$ret[$ret.length] = this.Items[i].ItemId;
}
}
return $ret;
}
Grid.prototype.SetSelected = function($ids) {
$ids = $ids.split(',');
for (var i in this.Items) {
if (in_array(this.Items[i].ItemId, $ids)) {
this.Items[i].Select();
}
}
}
Grid.prototype.InvertSelection = function() {
for (var i in this.Items)
{
if( this.Items[i].selected )
{
this.Items[i].UnSelect();
}
else
{
this.Items[i].Select();
}
}
this.CheckDependencies('Grid.InvertSelection');
}
Grid.prototype.SelectAll = function() {
for (var i in this.Items) {
this.Items[i].Select();
}
this.CheckDependencies('Grid.SelectAll');
this.ClearAlternativeGridsSelection('Grid.SelectAll');
}
Grid.prototype.SelectRangeUpTo = function( last_sequence ) {
for (var i in this.Items) {
if (this.Items[i].FallsInRange(this.LastSelectedSequence, last_sequence)) {
this.Items[i].Select();
}
}
}
Grid.prototype.CountSelected = function ()
{
return this.SelectedCount;
}
Grid.prototype.Edit = function() {
if ( this.CountSelected() == 0 ) return;
this.DblClick(this.prefix);
}
Grid.prototype.SetDependantToolbarButtons = function($buttons, $direct, $mode) {
if (!isset($direct)) $direct = true; // direct (use false for invert mode)
if (!isset($mode)) $mode = 1; // enable/disable (use 2 for show/hide mode)
for (var i = 0; i < $buttons.length; i++) {
this.DependantButtons.push(new Array($buttons[i], $direct, $mode));
}
//this.DependantButtons = buttons;
this.CheckDependencies('Grid.SetDependantToolbarButtons');
}
-Grid.prototype.CheckDependencies = function($called_from)
-{
-// alert('prefix: ' + this.prefix + '; ' + $called_from + ' -> Grid.CheckDependencies');
+Grid.prototype.CheckDependencies = function($called_from, $run_now) {
+ if (!$run_now || $run_now === undefined) {
+ // schedule run via document.ready, so we manage to disable
+ // toolbar buttons after ToolBar class mass-enables them
+ var $me = this;
+
+ $(document).ready(
+ function () {
+ $me.CheckDependencies($called_from, true);
+ }
+ );
+
+ return ;
+ }
+
var enabling = (this.CountSelected() > 0);
+
for (var i = 0; i < this.DependantButtons.length; i++) {
- if (this.DependantButtons[i][0].match("portal:(.*)")) {
- button_name = RegExp.$1;
- if (toolbar) {
- if (enabling == this.DependantButtons[i][1]) {
- toolbar.enableButton(button_name, true);
- }
- else
- {
- toolbar.disableButton(button_name, true);
- }
- }
+ if (this.DependantButtons[i][2] == 1) {
+ this.ToolBar.SetEnabled(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]);
}
else {
- if (this.DependantButtons[i][2] == 1) {
- this.ToolBar.SetEnabled(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]);
- }
- else {
- this.ToolBar.SetVisible(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]);
- }
+ this.ToolBar.SetVisible(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]);
}
}
- //if (enabling) this.ClearAlternativeGridsSelection('Grid.CheckDependencies');
-
}
Grid.prototype.ClearAlternativeGridsSelection = function (called_from)
{
$GridManager.ClearAlternativeGridsSelection(this.prefix);
}
Grid.prototype.AddAlternativeGrid = function (alt_grid, reciprocal)
{
var $dst_prefix = typeof('alt_grid') == 'string' ? alt_grid : alt_grid.prefix;
$GridManager.AddAlternativeGrid(this.prefix, $dst_prefix, reciprocal);
}
Grid.prototype.FirstSelected = function ()
{
min_sequence = null;
var res = null
for (var i in this.Items) {
if (!this.Items[i].selected) continue;
if (min_sequence == null)
min_sequence = this.Items[i].sequence;
if (this.Items[i].sequence <= min_sequence) {
res = this.Items[i].ItemId;
min_sequence = this.Items[i].sequence;
}
}
return res;
}
Grid.prototype.each = function($callback) {
var $result = null;
for (var i in this.Items) {
$result = $callback.call(this.Items[i], i);
if ($result === false) {
break;
}
}
}
\ No newline at end of file
Index: branches/5.0.x/core/admin_templates/js/toolbar.js
===================================================================
--- branches/5.0.x/core/admin_templates/js/toolbar.js (revision 13372)
+++ branches/5.0.x/core/admin_templates/js/toolbar.js (revision 13373)
@@ -1,378 +1,391 @@
function ToolBarButton(title, alt, onclick, $hidden, prefix)
{
this.Title = title || '';
this.TranslateLink = false;
this.CheckTitleModule();
this.Alt = RemoveTranslationLink(alt || '');
if (this.Alt != alt) {
this.TranslateLink = alt || '';
this.TranslateLink = this.TranslateLink.replace(/&lt;a href=&quot;(.*?)&quot;.*&gt;(.*?)&lt;\/a&gt;/g, '$1');
}
if (this.Alt.match(/(.*)::(.*)/)) {
this.Alt = RegExp.$1;
this.Label = RegExp.$2
}
else {
this.Label = this.Alt;
}
if (typeof(onclick) == 'function') {
this.onClick = onclick;
}
else {
this.onClick = function() {
if (eval('typeof('+this.Title+')') == 'function')
eval(this.Title + '()');
}
}
this.imgObject = null;
this.Enabled = true;
this.Hidden = $hidden ? true : false;
this.ToolBar = null;
this.Prefix = prefix ? prefix : '';
this.Separator = false;
}
ToolBarButton.prototype.CheckTitleModule = function()
{
if (this.Title.match(/([^:]+):(.*)$/)) {
// has module set directly
this.Title = RegExp.$2;
this.Module = RegExp.$1;
if (this.Module == 'in-portal') {
this.Module = 'kernel';
}
}
else {
// use default module
this.Module = 'core';
}
}
ToolBarButton.prototype.IconsPath = function()
{
if (typeof(img_path) == 'undefined') {
//alert('error: toolbar image path not set');
}
return img_path.replace('#MODULE#', this.Module) + 'toolbar/';
}
ToolBarButton.prototype.GetHTML = function() {
var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : '';
var o = '<div class="toolbar-button" id="'+this.GetToolID('div')+'" '+add_style+'>'
o += '<img id="' + this.GetToolID() + '" width="'+this.ToolBar.IconSize.w+'" height="'+this.ToolBar.IconSize.h+'" src="' + this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '.gif" title="' + this.Alt + '&nbsp;">';
if (this.ToolBar.UseLabels) o += '<br/>'+this.Label;
o += '</div>'
return o;
}
ToolBarButton.prototype.GetToolID = function(item) {
if (!item) item = 'tool'
return this.Prefix == '' ? item+'_' + this.Title : item+'_['+this.Prefix+'][' + this.Title+']'
}
ToolBarButton.prototype.Init = function() {
img = document.getElementById(this.GetToolID());
this.imgObject = img;
this.Container = document.getElementById(this.GetToolID('div')) ? document.getElementById(this.GetToolID('div')) : false;
this.Container.btn = this;
img.btn = this;
this.MouseOverImg = new Image();
this.MouseOverImg.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '_f2.gif';
this.MouseOutImg = new Image();
this.MouseOutImg.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '.gif';
this.SetOnMouseOver();
this.SetOnMouseOut();
this.SetOnClick();
this.SetOnRightClick()
if (this.Hidden) this.Hide();
+ // all buttons are disabled until page is fully loaded!
+ this.Disable();
+
if (!img.complete) {
var real_path = img_path.replace('#MODULE#', this.Module) + 'toolbar/';
var old_path = img_path.replace('#MODULE#', 'kernel') + 'toolbar/'+this.ToolBar.IconPrefix + this.Title+'.gif';
real_path = real_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.');
old_path = old_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.');
var source = old_path.replace('/core/', '/kernel/').replace('.gif', '*.gif');
var path = 'cp '+source+' '+real_path;
// prompt('exec: ', path)
// img.src = 'img/bad_button.GIF';
}
// preg_print_pre(img, /natural|compl/i)
}
ToolBarButton.prototype.EditTitle = function() {
if (this.TranslateLink !== false) {
var $links = this.TranslateLink;
$links = $links.split('::');
var $i = 0;
while ($i < $links.length) {
var $link = $links[$i];
if ($link.match(/(javascript:|http:\/\/)(.*)/)) {
var $link_type = RegExp.$1;
$link = RegExp.$2.replace(/&#[0]{0,1}39;/g, '"');
if ($link_type == 'javascript:') {
eval($link);
}
else {
window.location.href = 'http://' + $link;
}
// edit one phrase at a time
break;
}
$i++;
}
return false;
}
return true;
}
ToolBarButton.prototype.SetOnMouseOver = function() {
this.Container.onmouseover = function() {
this.btn.imgObject.src = this.btn.MouseOverImg.src;
this.className = 'toolbar-button-over';
};
}
ToolBarButton.prototype.SetOnMouseOut = function() {
this.Container.onmouseout = function() {
this.btn.imgObject.src = this.btn.MouseOutImg.src;
this.className = 'toolbar-button';
};
}
ToolBarButton.prototype.SetOnClick = function() {
// we have SetOnMouseOut for this ???
/*this.Container.onmouseout = function() {
this.btn.imgObject.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif';
};*/
this.Container.inClick = false;
if (typeof(this.onClick) != 'function') {
this.Container.onclick = function() {
if (this.inClick) return;
this.inClick = true;
if (eval('typeof('+this.btn.Title+')') == 'function')
eval(this.btn.Title + '()');
this.inClick = false;
}
}
else {
this.Container.onclick = function() {
if (this.inClick) return;
this.inClick = true;
this.btn.onClick();
this.inClick = false;
}
}
// the following lines are correct, as long as mozilla understands 'pointer', but IE 'hand',
// do not change the order of these lines!
if (is.ie6up || is.gecko) {
this.Container.style.cursor = 'pointer';
}
else {
// somehow set cursor hand for IE 5/ 5.5
// this.imgObject.style = 'cursor: hand';
}
}
ToolBarButton.prototype.SetOnRightClick = function() {
this.Container.oncontextmenu = function() {
return this.btn.EditTitle();
}
}
ToolBarButton.prototype.Disable = function() {
if ( !this.Enabled ) return;
if (typeof(this.DisabledImg) == 'undefined') {
this.DisabledImg = new Image();
this.DisabledImg.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '_f3.gif';
}
this.imgObject.src = this.DisabledImg.src;
this.Container.onmouseover = null;
this.Container.onmouseout = null;
this.Container.onclick = null;
this.Container.style.cursor = 'default';
this.Enabled = false;
this.Container.className = 'toolbar-button-disabled'
}
ToolBarButton.prototype.Enable = function() {
if (this.Enabled) return;
this.imgObject.src = this.MouseOutImg.src;
this.SetOnMouseOver();
this.SetOnMouseOut();
this.SetOnClick();
this.Enabled = true;
this.Container.className = 'toolbar-button'
}
ToolBarButton.prototype.Hide = function() {
this.Container.style.display = 'none';
this.Hidden = true;
}
ToolBarButton.prototype.Show = function() {
this.Container.style.display = '';
this.Hidden = false;
}
/* ----------- */
function ToolBarSeparator(title, $hidden) //extends ToolBarButton
{
this.Title = title;
this.Hidden = $hidden ? true : false;
this.Separator = true;
}
ToolBarSeparator.prototype = new ToolBarButton;
ToolBarSeparator.prototype.GetHTML = function() {
var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : '';
var padding = this.ToolBar.UseLabels ? '12px' : '2px'
return '<div id="'+this.GetToolID('div')+'" class="toolbar-button" style="padding-top: '+padding+'; height: 32px;" '+add_style+'><img id="' + this.GetToolID() + '" src="' + this.IconsPath() + 'tool_divider.gif"></div>';
var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : '';
return '<div id="'+this.GetToolID('div')+'" class="toolbar-button" style="border: 1px solid black; height: 100%;" '+add_style+'><img id="' + this.GetToolID() + '" src="' + this.IconsPath() + 'tool_divider.gif"></div>';
}
ToolBarSeparator.prototype.Init = function() {
img = document.getElementById(this.ToolBar.IconPrefix + this.Title);
this.Container = document.getElementById(this.GetToolID('div')) ? document.getElementById(this.GetToolID('div')) : false;
this.imgObject = img;
img.btn = this;
if (this.Hidden) {
this.Hide();
}
}
ToolBarSeparator.prototype.Enable = function() { }
ToolBarSeparator.prototype.Disable = function() { }
/* ----------- */
function ToolBarMarkup(title, html) //extends ToolBarButton
{
this.Title = title;
this.HTML = html;
}
ToolBarMarkup.prototype = new ToolBarButton;
ToolBarMarkup.prototype.GetHTML = function() {
return this.HTML;
}
ToolBarMarkup.prototype.Init = function() { }
ToolBarMarkup.prototype.Enable = function() { }
ToolBarMarkup.prototype.Disable = function() { }
/* ----------- */
function ToolBar(icon_prefix, $module)
{
this.Module = $module ? $module : 'core';
this.IconPrefix = icon_prefix ? icon_prefix : 'tool_';
this.IconSize = {w:32,h:32};
this.Buttons = {};
this.UseLabels = typeof($use_toolbarlabels) != 'undefined' ? $use_toolbarlabels : false;
}
ToolBar.prototype.AddButton = function(a_button)
{
if ($visible_toolbar_buttons === true || in_array(a_button.Title, $visible_toolbar_buttons) || a_button.Separator) {
a_button.ToolBar = this;
this.Buttons[a_button.Title] = a_button;
}
}
ToolBar.prototype._removeSeparators = function()
{
// TODO: find a way to cut first and last separators from non-indexed array, like $new_buttons.
var $separator = false;
var $new_buttons = {};
for (var $button_title in this.Buttons) {
if ($separator && this.Buttons[$button_title].Separator) {
continue;
}
$separator = this.Buttons[$button_title].Separator;
$new_buttons[$button_title] = this.Buttons[$button_title];
}
this.Buttons = $new_buttons;
}
ToolBar.prototype.Render = function($container)
{
// remove duplicate separators or separators at the end of button list
this._removeSeparators();
if ($container) {
var tmp = '';
for (var i in this.Buttons) {
btn = this.Buttons[i];
tmp += btn.GetHTML();
}
$container.innerHTML = tmp; // container will contain only buttons
// init all buttons after because objects are not yet created directly after assigning to innerHTML
for (var i in this.Buttons) {
btn = this.Buttons[i];
btn.Init();
}
}
else {
for (var i in this.Buttons) {
btn = this.Buttons[i];
document.write( btn.GetHTML() );
btn.Init();
}
}
+
+ var $me = this;
+
+ $(document).ready(
+ function () {
+ for (var $button_name in $me.Buttons) {
+ $me.Buttons[$button_name].Enable();
+ }
+ }
+ );
}
ToolBar.prototype.EnableButton = function(button_id) {
if(this.ButtonExists(button_id)) this.Buttons[button_id].Enable();
}
ToolBar.prototype.DisableButton = function(button_id) {
if(this.ButtonExists(button_id)) this.Buttons[button_id].Disable();
}
ToolBar.prototype.HideButton = function(button_id) {
if(this.ButtonExists(button_id)) this.Buttons[button_id].Hide();
}
ToolBar.prototype.ShowButton = function(button_id) {
if(this.ButtonExists(button_id)) this.Buttons[button_id].Show();
}
ToolBar.prototype.SetEnabled = function(button_id, $enabled) {
var $ret = $enabled ? this.EnableButton(button_id) : this.DisableButton(button_id);
}
ToolBar.prototype.SetVisible = function(button_id, $visible) {
var $ret = $visible ? this.ShowButton(button_id) : this.HideButton(button_id);
}
ToolBar.prototype.GetButtonImage = function(button_id) {
if( this.ButtonExists(button_id) ) return this.Buttons[button_id].imgObject;
}
ToolBar.prototype.ButtonExists = function(button_id) {
return typeof(this.Buttons[button_id]) == 'object';
}

Event Timeline