').addClass('tool-htmledit-wrap').insertBefore(this.targetElement);
this.wrap.data('editor', this);
this.targetElement.remove().appendTo(this.wrap);
this.CreateToolbar();
this.editor = $('
').appendTo(this.wrap);
this.editor
.attr('contenteditable', 'true')
.addClass('tool-htmledit-editor')
.bind('paste', this.HandlePaste)
//.css('min-height',(this.Height - 24) + 'px');
.height(this.Height - 24);
this.UpdateHtml();
var editorWidth = this.editor.width();
this.targetElement.width(editorWidth);
this.editor.width(editorWidth);
var w = this.wrap;
this.wrap.closest('form').bind('submit', function () { cms.HtmlEdit.OnSubmit(w); });
if ($.on) {
this.editor.on('click', 'img', cms.HtmlEdit.ClickImage);
} else {
if (cms.HtmlEdit.FallbackImageClickEnabled == false) {
cms.HtmlEdit.FallbackImageClickEnabled = true;
$('.tool-htmledit-editor img').live('click', cms.HtmlEdit.ClickImage);
}
}
this.editor.bind('mouseup', cms.HtmlEdit.UpdateSelection);
this.editor.bind('keyup', cms.HtmlEdit.__KeyUp);
this.editor.bind('keydown', cms.HtmlEdit.__KeyDown);
this.editor.bind('focus', cms.HtmlEdit.UpdateSelection);
$('body').mouseup(cms.HtmlEdit.UpdateSelectionWin);
this.editor.bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance);
var wx = this;
setTimeout(function () { wx.editor.css('max-width', wx.wrap.parent().width() - 32); }, 125);
//.blur(function () { document.designMode = 'off'; }).focus(function () { document.designMode = 'on'; })
};
cms.HtmlEdit.mouseDownSaveEditorInstance = function (e)
{
var editor = $(this);
cms.HtmlEdit.currentlySelectedEditor = editor;
};
cms.HtmlEdit.saveSelection = function()
{
if (window.getSelection) {
sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
var ranges = [];
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
ranges.push(sel.getRangeAt(i));
}
return ranges;
}
} else if (document.selection && document.selection.createRange) {
return document.selection.createRange();
}
return null;
};
cms.HtmlEdit.UpdateSelectionWin = function (e)
{
var currentEd = cms.HtmlEdit.currentlySelectedEditor;
if(currentEd != undefined)
{
var e = $(currentEd).closest('.tool-htmledit-wrap').data('editor');
}else
{
var e = $('.tool-htmledit-wrap').data('editor');
}
if (e) {
var sel = window.getSelection();
var selectionInfo = cms.HtmlEdit.saveSelection();
if (selectionInfo != null) {
if (selectionInfo.length > 0) {
e.LastSelection = selectionInfo;
}
}
e.UpdateToolbar(sel);
}
};
cms.HtmlEdit.UpdateSelection = function (e) {
var e = $(this).closest('.tool-htmledit-wrap').data('editor');
if (e) {
var sel = window.getSelection();
$('.tool-htmledit-img').removeClass('selected');
var isImg = false;
if (e.selectedImage) {
if (sel.containsNode && sel.containsNode(e.selectedImage[0],false)) {
e.selectedImage.addClass('selected');
isImg = true;
} else {
e.selectedImage = null;
}
}
if (isImg) {
e.baseToolbar.removeClass('active');
e.imageToolbar.addClass('active');
} else {
e.baseToolbar.addClass('active');
e.imageToolbar.removeClass('active');
}
var selectionInfo = cms.HtmlEdit.saveSelection();
if (selectionInfo != null) {
if (selectionInfo.length > 0) {
e.LastSelection = selectionInfo;
}
}
e.UpdateToolbar(sel);
}
};
cms.HtmlEdit.__KeyDown = function (e) {
var keycode = e.keyCode;
var printableChar =
(keycode > 47 && keycode < 58) || // number keys
keycode == 32 || keycode == 13 || // spacebar & return key(s) (if you want to allow carriage returns)
(keycode > 64 && keycode < 91) || // letter keys
(keycode > 95 && keycode < 112) || // numpad keys
(keycode > 185 && keycode < 193) || // ;=,-./` (in order)
(keycode > 218 && keycode < 223); // [\]' (in order)
cms.HtmlEdit.UpdateSelection(e);
var range = window.getSelection().getRangeAt(0);
//console.log(range.startContainer.parentNode);
var isButton = $(range.startContainer.parentNode).hasClass("i001-css-button");
if(printableChar && isButton)
{
// console.log("In button!");
return false; // In button - don't edit!
}
if (keycode == 8) {
var editor = $(this).closest('.tool-htmledit-wrap').data('editor');
if (editor.selectedImage && editor.selectedImage.length > 0) {
editor.selectedImage.remove();
editor.selectedImage = null;
e.stopPropagation();
e.preventDefault();
}
}
};
cms.HtmlEdit.__KeyUp = function (e) {
var keycode = e.keyCode;
var printableChar =
(keycode > 47 && keycode < 58) || // number keys
keycode == 32 || keycode == 13 || // spacebar & return key(s) (if you want to allow carriage returns)
(keycode > 64 && keycode < 91) || // letter keys
(keycode > 95 && keycode < 112) || // numpad keys
(keycode > 185 && keycode < 193) || // ;=,-./` (in order)
(keycode > 218 && keycode < 223); // [\]' (in order)
cms.HtmlEdit.UpdateSelection(e);
var range = window.getSelection().getRangeAt(0);
//console.log(range.startContainer.parentNode);
var isButton = $(range.startContainer.parentNode).hasClass("i001-css-button");
if(printableChar && isButton)
{
// console.log("In button!");
return false; // In button - don't edit!
}
if (keycode == 46 || keycode == 8) {
var editor = $(this).closest('.tool-htmledit-wrap').data('editor');
if (editor.selectedImage && editor.selectedImage.length > 0) {
editor.selectedImage.remove();
editor.selectedImage = null;
e.stopPropagation();
e.preventDefault();
}
}
};
CmsHtmlEdit.prototype.CreateButtonLink = function (sUri, noUndo, linkText) {
var gsp = this.GetSelectionParent('.tool-htmledit-wrap');
var ret = false;
if (gsp != null) {
if (gsp.length > 0) {
cms.HtmlEdit.__EnterDesignMode(this);
ret = document.execCommand('insertHTML',false,"
"+linkText+"");
cms.HtmlEdit.__ExitDesignMode(this);
}
}
return ret;
};
CmsHtmlEdit.prototype.getSelectionText = function() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
};
/* CLEAR IMAGE LINK */
cms.HtmlEdit.LinkParserRegex = /^\{\{([0-9]+):(-?[0-9]+)(;.+)?\}\}$/;
cms.HtmlEdit.ClearImageLink = function ()
{
var editor = $(this).closest('.tool-htmledit-wrap').data('editor');
if (editor.selectedImage && editor.selectedImage.length > 0)
{
var blah = $(editor.selectedImage).parent().get(0).tagName;
// test that parent is a link FIRST
if($(editor.selectedImage).parent().get(0).tagName.toLowerCase()=='a')
{
editor.selectedImage.unwrap();
}
baseUrl = editor.selectedImage.attr('data-link', '');
/* UNFINISHED */
}
};
cms.HtmlEdit.OpenLinkPicker = function ()
{
//var oLink = FCK.Selection.MoveToAncestorNode('A');
var editor = $(this).closest('.tool-htmledit-wrap').data('editor');
var oLink, baseUrl;
if (editor.selectedImage && editor.selectedImage.length > 0) {
oLink = editor.selectedImage[0];
baseUrl = editor.selectedImage.attr('data-link');
} else {
oLink = editor.GetSelectionParent('a');
baseUrl = '';
if (oLink && oLink.length > 0) {
var sel = window.getSelection();
sel.removeAllRanges();
var range = document.createRange();
range.selectNode(oLink[0]);
sel.addRange(range);
baseUrl = oLink.attr('href');
}
}
var oEditor = window;
// Open link picker popup and configure 'store' action.
var linkDialog = $('
').addClass('cms-picker-loader').attr('title', 'Choose or enter a link destination');
var dConfig = {
bgiframe: true,
modal: true,
width: 700,
height: 500,
dialogClass: 'cms-picker-loader'
};
$('body').unbind('mouseup');
$(this).closest('.tool-htmledit-wrap').unbind('mousedown');
linkDialog.dialog(dConfig);
var sUrl = cms.RootPath + '/p.ashx?t=268570528&d=2&p.lr=' + cms.LinkRenderId;
window.curDialogBaseUrl = sUrl;
if (baseUrl != null && baseUrl != '') {
// Interpret supplied URL
var isObject = 0;
var x = cms.HtmlEdit.LinkParserRegex.exec(baseUrl);
if (x != null && x.length > 0) {
isObject = 1;
sUrl += '&lv.tgt_type=' + parseInt(x[1]);
sUrl += '&lv.tgt_id=' + parseInt(x[2]);
sUrl += '&lv.link_type=' + (x[3] != null && x[3].match(/attach/i) ? 1 : 0);
} else {
sUrl += '&lv.raw=' + encodeURIComponent(baseUrl);
}
sUrl += '&lv.internal=' + isObject;
}
linkDialog.load(sUrl, null, function () { linkDialog.closest('.ui-dialog').removeClass('cms-picker-loader') });
window.storeCmsLink = function (sUri, sContent) {
if (editor.selectedImage && editor.selectedImage.length > 0) {
editor.selectedImage.attr('data-link', sUri);
/* ********************************** */
/* This is where the editor needs to create a link */
console.log(editor.selectedImage);
sInnerHtml = sContent;
if($(editor.selectedImage).parent().get(0).tagName.toLowerCase()!='a')
{
$(editor.selectedImage).wrap('
');
}
else
{
$(editor.selectedImage).unwrap();
$(editor.selectedImage).wrap('
');
}
} else {
// If no link is selected, create a new one (it may result in more than one link creation - #220).
//if ($.browser.msie)
//sRange.select();
//else
cms.HtmlEdit.restoreSelection(editor.LastSelection);
var selX = window.getSelection();
if (selX == null || selX.isCollapsed == true) {
var aLinks = oLink == null ? [] : [$(oLink)];
// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
var aHasSelection = (aLinks.length > 0);
if (!aHasSelection) {
// Is internal link?
var x = cms.HtmlEdit.LinkParserRegex.exec(sUri);
if (x != null && x.length > 0 && sContent == null) {
var ajaxUrl = cms.RootPath + '/wf.ashx?f=obj.title&t=' + parseInt(x[1]) + '&d=' + parseInt(x[2]);
$.get(ajaxUrl, function (data, textStatus) { window.storeCmsLink(sUri, data); });
return;
} else if (sContent == null) {
sContent = sUri;
}
sInnerHtml = sContent;
// Create a new (empty) anchor.
oLink = $('
').attr('href', sUri).html(sInnerHtml);
aLinks = [oLink];
editor.InsertElement(oLink);
}
for (var i = 0; i < aLinks.length; i++)
{
oLink = aLinks[i];
if (aHasSelection)
{
sInnerHtml = oLink.html(); // Save the innerHTML (IE changes it if it is like an URL).
}
oLink.attr('href', sUri);
//SetAttribute(oLink, '_fcksavedurl', sUri);
try { oLink.html(sInnerHtml); } // Set (or restore) the innerHTML
catch (e) { }
}
} else {
editor.CreateLink(sUri, true);
}
}
// Select the (first) link.
//oEditor.FCKSelection.SelectNode(aLinks[0]);
linkDialog.dialog('close');
linkDialog.remove();
$('body').mouseup(cms.HtmlEdit.UpdateSelectionWin);
$(this).closest('.tool-htmledit-wrap').bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance);
window.storeCmsLink = null;
window.curDialogBaseUrl = null;
};
};
cms.HtmlEdit.dragButtonMouseDown = function (e)
{
cms.HtmlEdit.dragButtonMode = true;
cms.HtmlEdit.dragButtonObject = $(this);
};
cms.HtmlEdit.dragButtonMouseUp = function (e)
{
cms.HtmlEdit.dragButtonMode = false;
};
cms.HtmlEdit.dragButtonMouseMove = function (e)
{
if(cms.HtmlEdit.dragButtonMode==true)
{
$(cms.HtmlEdit.dragButtonObject).offset().x = e.pageX;
$(cms.HtmlEdit.dragButtonObject).offset().y = e.pageY;
}
};
cms.HtmlEdit.CreateButton = function () {
var editor = $(this).closest('.tool-htmledit-wrap').data('editor');
var oLink, baseUrl;
oLink = editor.GetSelectionParent('a');
baseUrl = '';
if (oLink && oLink.length > 0) {
var sel = window.getSelection();
sel.removeAllRanges();
var range = document.createRange();
range.selectNode(oLink[0]);
sel.addRange(range);
baseUrl = oLink.attr('href');
}
var oEditor = window;
// Open link picker popup and configure 'store' action.
var linkDialog = $('').addClass('cms-picker-loader').attr('title', 'Choose or enter a link destination');
var dConfig = {
bgiframe: true,
modal: true,
width: 700,
height: 500,
dialogClass: 'cms-picker-loader'
};
$('body').unbind('mouseup');
$(this).closest('.tool-htmledit-wrap').unbind('mousedown');
linkDialog.dialog(dConfig);
var sUrl = cms.RootPath + '/p.ashx?t=268570528&d=2&p.lr=' + cms.LinkRenderId;
window.curDialogBaseUrl = sUrl;
if (baseUrl != null && baseUrl != '') {
// Interpret supplied URL
var isObject = 0;
var x = cms.HtmlEdit.LinkParserRegex.exec(baseUrl);
if (x != null && x.length > 0) {
isObject = 1;
sUrl += '&lv.tgt_type=' + parseInt(x[1]);
sUrl += '&lv.tgt_id=' + parseInt(x[2]);
sUrl += '&lv.link_type=' + (x[3] != null && x[3].match(/attach/i) ? 1 : 0);
} else {
sUrl += '&lv.raw=' + encodeURIComponent(baseUrl);
}
sUrl += '&lv.internal=' + isObject;
}
linkDialog.load(sUrl, null, function () { linkDialog.closest('.ui-dialog').removeClass('cms-picker-loader') });
window.storeCmsLink = function (sUri, sContent) {
if (editor.selectedImage && editor.selectedImage.length > 0) {
editor.selectedImage.attr('data-link', sUri);
} else {
// If no link is selected, create a new one (it may result in more than one link creation - #220).
//if ($.browser.msie)
//sRange.select();
//else
cms.HtmlEdit.restoreSelection(editor.LastSelection);
var selX = window.getSelection();
if (selX == null || selX.isCollapsed == true) { // here
var aLinks = oLink == null ? [] : [$(oLink)];
// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
var aHasSelection = (aLinks.length > 0);
if (!aHasSelection) {
// Is internal link?
var x = cms.HtmlEdit.LinkParserRegex.exec(sUri);
if (x != null && x.length > 0 && sContent == null) {
var ajaxUrl = cms.RootPath + '/wf.ashx?f=obj.title&t=' + parseInt(x[1]) + '&d=' + parseInt(x[2]);
$.get(ajaxUrl, function (data, textStatus) { window.storeCmsLink(sUri, data); });
return;
} else if (sContent == null) {
sContent = sUri;
}
sInnerHtml = sContent;
// Create a new (empty) anchor.
oLink = $('').attr('href', sUri).html(sInnerHtml).after('
');
$(oLink).addClass('i001-css-button new_v01 tool-htmledit-img');
$(oLink).before('
');
aLinks = [oLink];
editor.InsertElement(oLink);
/*
// enable drag and drop for image
$(".tool-htmledit-editor").unbind('mousedown');
$(".tool-htmledit-editor").unbind('mouseup');
$(".tool-htmledit-editor").mousedown(cms.HtmlEdit.dragButtonMouseDown);
$(".tool-htmledit-editor").mouseup(cms.HtmlEdit.dragButtonMouseUp);
$(".tool-htmledit-editor").mousemove(cms.HtmlEdit.dragButtonMouseMove);
*/
}
for (var i = 0; i < aLinks.length; i++) {
oLink = aLinks[i];
if (aHasSelection)
sInnerHtml = oLink.html(); // Save the innerHTML (IE changes it if it is like an URL).
oLink.attr('href', sUri);
//SetAttribute(oLink, '_fcksavedurl', sUri);
try { oLink.html(sInnerHtml); } // Set (or restore) the innerHTML
catch (e) { }
}
} else {
selectionText = editor.getSelectionText();
editor.CreateButtonLink(sUri, true, selectionText);
}
}
// Select the (first) link.
//oEditor.FCKSelection.SelectNode(aLinks[0]);
linkDialog.dialog('close');
linkDialog.remove();
$('body').mouseup(cms.HtmlEdit.UpdateSelectionWin);
$(this).closest('.tool-htmledit-wrap').bind('mousedown', cms.HtmlEdit.mouseDownSaveEditorInstance);
window.storeCmsLink = null;
window.curDialogBaseUrl = null;
};
};
cms.HtmlEdit.ClickToolbarItem = function (e) {
var editor = $(this).data('editor');
var item = $(this).data('item');
//cms.HtmlEdit.restoreSelection(editor.LastSelection);
// Check collapsed
var sel = window.getSelection();
if (sel.isCollapsed == true) {
var range = document.createRange();
range.selectNode(sel.focusNode);
sel.removeAllRanges();
sel.addRange(range);
}
var ret = false;
var proceed = true;
if (item.func == 'insertunorderedlist') {
var parentUl = $(sel.focusNode).closest('.tool-htmledit-editor ul');
var parentOl = $(sel.focusNode).closest('.tool-htmledit-editor ol');
if (parentUl.length > 0) {
// Remove List
var newContainer = $('');
parentUl.children('li').each(function () {
$(this).contents().appendTo($('').appendTo(newContainer));
});
newContainer.insertBefore(parentUl);
parentUl.remove();
proceed = false;
} else if (parentOl.length > 0) {
// Move list
var newList = $('
').insertBefore(parentOl);
parentOl.children().appendTo(newList);
parentOl.remove();
proceed = false;
}
} else if (item.func == 'insertorderedlist') {
var parentUl = $(sel.focusNode).closest('.tool-htmledit-editor ul');
var parentOl = $(sel.focusNode).closest('.tool-htmledit-editor ol');
if (parentOl.length > 0) {
// Remove List
var newContainer = $('');
parentOl.children('li').each(function () {
$(this).contents().appendTo($('').appendTo(newContainer));
});
newContainer.insertBefore(parentOl);
parentOl.remove();
proceed = false;
} else if (parentUl.length > 0) {
// Move list
var newList = $('
').insertBefore(parentUl);
parentUl.children().appendTo(newList);
parentUl.remove();
proceed = false;
}
}
if (proceed) {
cms.HtmlEdit.__EnterDesignMode(this);
ret = document.execCommand(item.func, false, item.param);
cms.HtmlEdit.__ExitDesignMode(this);
}
e.preventDefault();
e.stopPropagation();
//cms.HtmlEdit.restoreSelection(editor.LastSelection);
editor.UpdateToolbar(window.getSelection());
return ret;
};
/* Toolbar */
CmsHtmlEdit.prototype.ToolbarItems = [
{
label: 'Style', func: '_style', styleList: [], styleFunc: function () {
var list = [
//{ name: 'Heading 1', element: 'h1' },
//{ name: 'Heading 2', element: 'h2' },
{ name: 'Heading 1', element: 'h3' },
{ name: 'Heading 2', element: 'h4' },
{ name: 'Heading 3', element: 'h5' },
{ name: 'Heading 4', element: 'h6' },
{ name: 'Body Text', element: 'p' },
{ name: 'Body Text Larger', element: 'p', cssClass: 'es-larger' },
{ name: 'Intro Paragraph', element: 'p', cssClass: 'es-intro' },
{ name: 'Feature Paragraph', element: 'p', cssClass: 'es-feature' },
{ name: 'Standout Quote 1', element: 'p', cssClass: 'es-quote' },
{ name: 'Standout Quote 2', element: 'p', cssClass: 'es-quote2' },
{ name: 'Standout Quote 3', element: 'p', cssClass: 'es-quote3' },
{ name: 'Fine Print', element: 'p', cssClass: 'es-fineprint' }
]
if (local && local.__resetStyles == true) { list = []; }
if (local && local.extraEditorStyles && local.extraEditorStyles.length > 0) { list = list.concat(local.extraEditorStyles); }
return list;
}
},
{
label: 'Colour', func: '_style', sprite: 'colour', styleList: [], styleFunc: function () {
var list = cms.__GetColourStyles();
if (list.length > 0) { list.push({ name: 'Default', cssClass: '' }); }
return list;
}
},
{
label: 'Appearance', func: '', sprite: 'appearance', children: [
{ label: 'Bold', sprite: 'bold', func: 'bold', prop: 'font-weight', val: 'bold' },
{ label: 'Italic', sprite: 'italic', func: 'italic', prop: 'font-style', val: 'italic' },
{ label: 'Underline', sprite: 'underline', func: 'underline', prop: 'text-decoration', val: 'underline' },
{ label: 'Remove Formatting', sprite: 'clear', func: 'removeformat' }
]
},
{
label: 'Align', func: '', sprite: 'align', children: [
{ label: 'Left', sprite: 'left', func: 'JustifyLeft', prop: 'text-align', val: 'left' },
{ label: 'Centre', sprite: 'centre', func: 'JustifyCenter', prop: 'text-align', val: 'center' },
{ label: 'Right', sprite: 'right', func: 'JustifyRight', prop: 'text-align', val: 'right' },
{ label: 'Full Justify', sprite: 'full', func: 'JustifyFull', prop: 'text-align', val: 'justify' }
]
},
//{ label: 'Adjust', func: '', sprite: 'adjust' },
{
label: 'List Options', func: '', sprite: 'lists', children: [
{ label: 'Bullet List', sprite: 'list_bullet', func: 'insertunorderedlist', isActive: function (e) { var sel = window.getSelection(); return sel && sel.focusNode && $(sel.focusNode).closest('ul').length > 0; } },
{ label: 'Numbered List', sprite: 'list_num', func: 'insertorderedlist', isActive: function (e) { var sel = window.getSelection(); return sel && sel.focusNode && $(sel.focusNode).closest('ol').length > 0; } }
]
},
{ label: 'Create Link', sprite: 'link', exec: cms.HtmlEdit.OpenLinkPicker },
{ label: 'Remove Link', sprite: 'unlink', func: 'unlink' },
{ label: 'Create Button', sprite: 'editor_button', exec: cms.HtmlEdit.CreateButton },
{ label: 'Insert Image', sprite: 'image', exec: cms.HtmlEdit.OpenImagePicker },
//{ label: 'Spell Check', sprite: 'spellcheck', func: 'spellcheck' },
{
label: 'View Source', sprite: 'source', extraClass: 'right', exec: function () {
var w = $(this).closest('.tool-htmledit-wrap');
var e = w.data('editor');
if (w.hasClass('show-source')) {
e.UpdateHtml();
} else {
e.UpdateTextarea();
}
w.toggleClass('show-source');
$(this).toggleClass('active');
e.Focus();
}
}
];
CmsHtmlEdit.prototype.ImageToolbarItems = [
{
label: 'Float Left', sprite: 'img_left',
isActive: function (e) { return e.selectedImage && e.selectedImage.hasClass('left'); },
exec: function () {
var e = $(this).closest('.tool-htmledit-wrap').data('editor');
e.GetSelectedImage();
if (e.selectedImage) {
e.selectedImage.addClass('left').removeClass('right');
}
e.UpdateToolbar();
}
},
{
label: 'Float Right', sprite: 'img_right',
isActive: function (e) { return e.selectedImage && e.selectedImage.hasClass('right'); },
exec: function () {
var e = $(this).closest('.tool-htmledit-wrap').data('editor');
e.GetSelectedImage();
if (e.selectedImage) {
e.selectedImage.removeClass('left').addClass('right');
}
e.UpdateToolbar();
}
},
{
label: 'Full Width', sprite: 'img_full',
isActive: function (e) { return e.selectedImage && e.selectedImage.hasClass('left') == false && e.selectedImage.hasClass('right') == false; },
exec: function () {
var e = $(this).closest('.tool-htmledit-wrap').data('editor');
e.GetSelectedImage();
if (e.selectedImage) {
e.selectedImage.removeClass('left').removeClass('right');
}
e.UpdateToolbar();
}
},
{ label: 'Create Link', sprite: 'link', exec: cms.HtmlEdit.OpenLinkPicker },
{ label: 'Remove Link', sprite: 'unlink', exec: cms.HtmlEdit.ClearImageLink },
{
label: 'View Source', sprite: 'source', extraClass: 'right', exec: function () {
var w = $(this).closest('.tool-htmledit-wrap');
var e = w.data('editor');
if (w.hasClass('show-source')) {
e.UpdateHtml();
} else {
e.UpdateTextarea();
}
w.toggleClass('show-source');
$(this).toggleClass('active');
e.Focus();
}
}
];
cms.__GetColourStyles = function() { return [
{ name: 'Body Text', cssClass: 'tc-bodytext' },
{ name: 'Feature A', cssClass: 'tc-featureA' },
{ name: 'Feature B', cssClass: 'tc-featureB' },
{ name: 'Feature C', cssClass: 'tc-featureC' }
] };
/* TemplateFilter 0x10C80FA1000009CA */
JQTWEET = {
user: 'biancaboard',
numTweets: 5,
appendTo: '#jqtweet',
// core function of jqtweet
loadTweets: function(target,username,count) {
$.ajax({
url: 'http://api.twitter.com/1/statuses/user_timeline.json/',
type: 'GET',
dataType: 'jsonp',
data: {
screen_name: username,
include_rts: true,
count: count,
include_entities: true
},
success: function(data, textStatus, xhr) {
var html = '';
// append tweets into page
for (var i = 0; i < data.length; i++) {
$(target).append(
html.replace('TWEET_TEXT', JQTWEET.ify.clean(data[i].text) )
.replace(/USER/g, data[i].user.screen_name)
.replace(/ID/g, data[i].id_str)
);
}
$(target).cycle({
timeout: 7000
});
}
});
},
/**
* The Twitalinkahashifyer!
* http://www.dustindiaz.com/basement/ify.html
* Eg:
* ify.clean('your tweet text');
*/
ify: {
link: function(tweet) {
return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) {
var http = m2.match(/w/) ? 'http://' : '';
return '' + ((m1.length > 25) ? m1.substr(0, 24) + '...' : m1) + '' + m4;
});
},
at: function(tweet) {
return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20})/g, function(m, username) {
return '@' + username + '';
});
},
list: function(tweet) {
return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20}\/\w+)/g, function(m, userlist) {
return '@' + userlist + '';
});
},
hash: function(tweet) {
return tweet.replace(/(^|\s+)#(\w+)/gi, function(m, before, hash) {
return before + '#' + hash + '';
});
},
clean: function(tweet) {
return this.hash(this.at(this.list(this.link(tweet))));
}
} // ify
};
/* TemplateFilter 0x10C80FA1000009CC */
local.initSocialHover = function(){
if(local._isSocialInit == false){
var src = '';
var hsrc = '';
$('.d_sm-item img').hover(function(){
var tgt = $(this);
src = tgt.attr('src');
hsrc = tgt.attr('data-hover');
tgt.attr('src',hsrc);
}, function(){
var tgt = $(this);
tgt.attr('src',src);
});
local._isSocialInit = true;
}
};
local._isSocialInit = false;
/* TemplateFilter 0x10C80FA1000009CE */
local.initBannerGallery = function(){
var tgt = $('.t115-banner-gallery-wrapper.hp');
var h = $(window).height();
tgt.height(h - 84);
$(window).resize(function(){
var h = $(window).height();
tgt.height(h- 84);
});
};
/*
* jQuery OnDemand Image Loader
*
* Developed by
* Copyright 2011 - Anthony McLin
* http://anthonymclin.com
* Version 1.0
* Licensed under GPLv2
*
* Extended by Simon Willcock - 2012
*/
(function($){
$.fn.onDemandLoader = function(options) {
// Configuration
options = $.extend({
selector: null,
spinner: null,
background: null,
callback : jQuery.noop
}, options);
//Change the source of all the images to point to the loading image
$(options.selector).each( function() {
if(options.background != true){
//Write the original source to a temporary location
$(this).attr('data-src', $(this).attr('src'));
//Change the image source to the loading image
$(this).attr('src', options.spinner);
} else {
var img = $(this).css('background-image');
$(this).attr('data-src',img).attr('data-bg','true');
$(this).css('background-image', 'url('+options.spinner+')');
}
});
};
//Load a specific image by changing the source back
$.fn.onDemandLoader.loadImage = function(img) {
if($(img).attr('data-bg') !== undefined){
$(img).css('background-image', $(img).attr('data-src'));
} else {
$(img).attr('src', $(img).attr('data-src'));
}
};
})(jQuery);