").appendTo(this.element).igTablePropertiesDialog({item:table,target:plgUI.toolbarItem,applyform:function(e,ui){self._selectionWrapperSaved.insertTable(ui.table)}});return}if(this.insertTableDialog.igTablePropertiesDialog("option","isHidden")){this.insertTableDialog.igTablePropertiesDialog("show",table);return}if(!this.insertTableDialog.igTablePropertiesDialog("option","isHidden")){this.insertTableDialog.igTablePropertiesDialog("hide")}},_addTableRowPlg:function(){var selectedItem=this._selectionWrapperSaved.getSelectedItem();if(selectedItem.is("table")){selectedItem.tableManipulator("addRow")}else if(selectedItem.is("td")){selectedItem.parents("table").first().tableManipulator("addRow",selectedItem.parent().index())}},_removeTableRowPlg:function(){var selectedItem=this._selectionWrapperSaved.getSelectedItem();if(selectedItem.is("table")){selectedItem.tableManipulator("removeRow")}else if(selectedItem.is("td")){selectedItem.parents("table").first().tableManipulator("removeRow",selectedItem.parent().index())}},_addTableColumnPlg:function(){var selectedItem=this._selectionWrapperSaved.getSelectedItem();if(selectedItem.is("table")){selectedItem.tableManipulator("addColumn")}else if(selectedItem.is("td")){selectedItem.parents("table").first().tableManipulator("addColumn",selectedItem.index())}},_removeTableColumnPlg:function(){var selectedItem=this._selectionWrapperSaved.getSelectedItem();if(selectedItem.is("table")){selectedItem.tableManipulator("removeColumn")}else if(selectedItem.is("td")){selectedItem.parents("table").first().tableManipulator("removeColumn",selectedItem.index())}},_fontColorPlg:function(workspace,ui){if(/^rgb/.test(ui.value)){ui.value=$.ig.util.rgbToHex(ui.value)}this._execCommand("forecolor",ui.value)},_fontBackgroundColorPlg:function(workspace,ui){var command=this._getFirefoxVersion()?"hilitecolor":"backcolor";this._execCommand(command,ui.value)},_domPathToolbar:function(){var self=this,tableItemPref="#"+this._id("_toolbars_insertObjectToolbar_item_"),tableItemAddRowID=tableItemPref+"addRow",tableItemAddColID=tableItemPref+"addColumn",tableItemRemRowID=tableItemPref+"removeRow",tableItemRemColID=tableItemPref+"removeColumn",doNotEnableToolbarButtonsSelector=tableItemAddRowID+", "+tableItemAddColID+", "+tableItemRemRowID+", "+tableItemRemColID;this._viewSourceBtn=$('
').appendTo(this.element).igButton({labelText:" ",title:this._getLocaleValue("viewSourceButtonTitle"),icons:{primary:"ui-igbutton-viewsource-icon"},onlyIcons:true,click:function(){self._viewSourcePlg();if(self._domPathToolbar.igPathFinder("option","disabled")){self._domPathToolbar.igPathFinder("option","disabled",false);self._toolbars.find(":ui-igToolbarButton").not(doNotEnableToolbarButtonsSelector).igToolbarButton("option","disabled",false).end().end().find(":ui-igCombo").igCombo("enable");self._analyser._disableUnsupportedItems();self._onSelectionChange()}else{self._domPathToolbar.igPathFinder("option","disabled",true);self._toolbars.find(":ui-igToolbarButton").igToolbarButton("option","disabled",true).end().find(":ui-igCombo").igCombo("disable")}}}).attr({"data-localeid":"viewSourceButtonTitle","data-localeattr":"title"});this._domPathToolbar=$('
').appendTo(this.element).igPathFinder({click:function(e,ui){var selectionWrapper=self._selectionWrapperSaved;self.workspace.contentWindow.document.body.focus();if(self._domPathToolbar.igPathFinder("option","disabled")){return}e.preventDefault();if(ui.item.is("html")){selectionWrapper.select(ui.item.children("body"))}else if(ui.item.is("body")){selectionWrapper.select(ui.item)}else{selectionWrapper.select(ui.item)}}})},_onSelectionChange:function(callback){var self=this,selectionWrapper,workSpaceBody=$(this.workspace).contents().find("body"),selectionCallback=callback||function(){var selectedItem=this.getSelectedItem();if(selectedItem&&(selectedItem.is("p")||selectedItem.is(":header"))&&selectedItem.children("span").length>0){selectedItem=selectedItem.children("span").first()}else if(selectedItem&&(selectedItem.is("p")||selectedItem.is(":header"))&&selectedItem.children("font").length>0){selectedItem=selectedItem.children("font").first()}if(selectedItem[0].nodeType===self.NODE._Text){selectedItem=selectedItem.parent()}self._analyser.analyse(selectedItem);if(selectedItem.length){self._domPathToolbar.igPathFinder("option","items",$.merge(selectedItem,selectedItem.parents()))}};selectionWrapper=new $.ig.SelectionWrapper(this.workspace.contentWindow,function(){self._selectionWrapperSaved=this;self.sourceWindow.val(encodeURIComponent(workSpaceBody.html()));selectionCallback.call(this)})},_destroyPopovers:function(){var el=this.element[0];$(':data("igPopover")').each(function(){if($.contains(el,this)){$(this).igPopover("destroy")}})},resizeWorkspace:function(){var $clonedElement,height=this.element.height(),$editor=$("#"+this._id("_editor")),$toolbars=$("#"+this._id("_toolbars"));if(!$toolbars.is(":visible")){$clonedElement=$toolbars.clone();$clonedElement.css({display:"initial",position:"absolute",top:"-10000px",width:this.element.width()});$("body").append($clonedElement);height-=$clonedElement.height()+$toolbars.outerHeight(true);$clonedElement.remove()}else{height-=$toolbars.outerHeight(true)}height-=$(".ui-igbutton-viewsource").outerHeight(true);height-=$editor.outerHeight(true)-$editor.height();$editor.height(height);$("#"+this._id("_source")).height(height)},getContent:function(format){if(format==="text"){return $(this.workspace).contents().find("body").text()}if(format==="html"){return $(this.workspace).contents().find("body").html()}},setContent:function(content,format){if(format==="text"){$(this.workspace).contents().find("body").text(content)}else if(format==="html"){$(this.workspace).contents().find("body").html(content)}this.sourceWindow.val(encodeURIComponent(content))},destroy:function(){this._superApply(arguments);$(this.workspace.contentWindow).undelegate();this._destroyPopovers();this._viewSourceBtn.igButton("destroy");this.element.removeClass(this.css.htmlEditor).find("#"+this._id("_content")).removeClass(this.css.htmlEditorContent).end().find("#"+this._id("_domPathToolbar")).removeClass(this.css.pathFinder).end().find("#"+this._id("_toolbars")).removeClass(this.css.toolbarsContainer).end().find(":ui-igToolbar").igToolbar("destroy").end().empty()},executeAction:function(actionName,args){this._selectionWrapperSaved.execCommand(actionName.toLowerCase(),args);this._onSelectionChange()},isDirty:function(){return this._isDirty},contentWindow:function(){return this.workspace.contentWindow},contentDocument:function(){return this.contentWindow().document},contentEditable:function(){return this.contentDocument().body},selection:function(){return this._selectionWrapperSaved._getSelection()},range:function(){return this._selectionWrapperSaved._getRange()},insertAtCaret:function(element){var el,range;if($.ig.util.isDomElement(element)){element=$(element)}if(element instanceof $){element=$("
").append(element).html()}else if(typeof element!=="string"){return}el=$(element,this._selectionWrapperSaved._document)[0];range=this.range();range.insertNode(el)}});$.widget("ui.igPathFinder",{options:{items:null},css:{button:"ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only "+"ui-igbutton ui-widget-content",buttonLabel:"ui-button-text",stateDefault:"ui-state-default",firstButton:"ui-first-button",overflowMarker:"ui-igpathfinder-overflowMarker"},_create:function(){var self=this,o=this.options;this._addStyles();this.element.attr("disabled",o.disabled).attr("aria-disabled",o.disabled).on("mouseover","div",function(){if(!o.disabled){$(this).addClass("ui-state-hover")}}).on("mouseleave","div",function(){if(!o.disabled){$(this).removeClass("ui-state-hover")}}).on("click","div",function(e){if(!o.disabled){$(this).siblings(".ui-state-active").removeClass("ui-state-active");$(this).addClass("ui-state-active");self._trigger("click",e,{item:self.options.__currentParents.eq(self.options.__currentButtonList.index(this))})}})},_addStyles:function(){this.element.addClass("ui-igPathFinder")},_setOption:function(name,value){$.Widget.prototype._setOption.apply(this,arguments);switch(name){case"items":this._updateToolbar();break;case"disabled":this.element.toggleClass("ui-state-disabled",!!value).attr("aria-disabled",value);break;default:break}},_addOverflowMarker:function(){var overflowMarker=$("
...
").addClass(this.css.overflowMarker).addClass(this.css.stateDefault);overflowMarker.prependTo(this.element)},_updateToolbar:function(){var i,parents,btn,buttonsList,self=this,o=this.options,path=[],html="",viewSrcBtn=$(".ui-igbutton-viewsource"),overflowMarkerWidth=20,maxWidth=viewSrcBtn.parent().width()-viewSrcBtn.outerWidth(true)-overflowMarkerWidth,maxWidthReached=false;if(o.items.length){o.items.each(function(index,element){html='
'+''+element.nodeName+""+"
";path.push(html)});this.element.empty();parents=$(o.items.toArray().reverse());buttonsList=$(path.reverse().join(""));for(i=buttonsList.length-1;i>=0&&!maxWidthReached;i--){buttonsList.removeClass(this.css.firstButton);btn=buttonsList.eq(i).addClass(this.css.firstButton).prependTo(this.element);if(i===0){maxWidth+=overflowMarkerWidth}if(this.element.outerWidth(true)>maxWidth){btn.remove();buttonsList.eq(i+1).addClass(this.css.firstButton);this._addOverflowMarker();maxWidthReached=true}}this.options.__currentButtonList=buttonsList;this.options.__currentParents=parents}}});$.widget("ui.igHtmlEditorPopover",$.ui.igWidget,{localeWidgetName:"HtmlEditor",options:{item:null,target:null,isHidden:true},css:{igHtmlEditorPropertiesDialog:"ui-ightmleditor-dialog",igHtmlEditorPropertiesDialogContainer:"ui-ightmleditor-dialog-container"},events:{apply:"applyform",cancel:"cancelform",show:"show",hide:"hide"},_id:function(id){return this.element[0].id+id},_create:function(){this.element.igPopover({closeOnBlur:false,position:"balanced",direction:"bottom",renderCloseButton:false,showOn:null,maxWidth:"90%",width:"95%",maxHeight:"300px",minWidth:"160px"});this.poContent=this.element.igPopover("container");this._createForm()},_init:function(){this._item=this.options.item;this.poContent.addClass(this.css.igHtmlEditorPropertiesDialog);this.element.addClass(this.css.igHtmlEditorPropertiesDialogContainer);this._attachFormEvents();this.show(this._item)},_createForm:function(){},_attachFormEvents:function(){},_dataBind:function(){},show:function(item){this._item=item;this._dataBind(item);this.options.isHidden=false;this.element.igPopover("show",this.options.target);this._trigger(this.events.show)},hide:function(){this.options.isHidden=true;if(this.options.target.igToolbarButton("option","isSelected")){this.options.target.igToolbarButton("toggle")}this.element.igPopover("hide");this._trigger(this.events.hide)}});$.widget("ui.igLinkPropertiesDialog",$.ui.igHtmlEditorPopover,{_txtUrl:"",_cbTarget:"",_attachFormEvents:function(){var self=this;this.poContent.find("#"+this._id("_cmbOpenIn")).igCombo({initialSelectedItems:[{index:0}],enableClearButton:false,width:"100%",mode:"dropdown"});this.poContent.find("#"+this._id("_btnCancel")).igButton({click:function(){self.hide()}});this.poContent.find("#"+this._id("_btnApply")).igButton({click:function(e){e.stopImmediatePropagation();self._item.attr({href:self._txtUrl.val(),target:self._cbTarget.igCombo("value")}).html(self._displayText.val().length>0?self._displayText.val():self._txtUrl.val());self._trigger(self.events.apply,e,{anchor:self._item});self.hide()}});this.poContent.bind("keypress",function(e){if(e.keyCode===$.ui.keyCode.ESCAPE){self.hide()}});this.element.bind("igpopovershown",function(){self.poContent.find("#"+self._id("_linkHref")).focus()})},_createForm:function(){var html="";html+="
";$(html).appendTo(this.poContent)},_dataBind:function(anchor){this._txtUrl=this.poContent.find("#"+this._id("_linkHref")).val(anchor.attr("href"));this._cbTarget=this.poContent.find("#"+this._id("_cmbOpenIn")).val(anchor.attr("target"));this._displayText=this.poContent.find("#"+this._id("_linkDisplayText")).val(anchor.html())}});$.widget("ui.igTablePropertiesDialog",$.ui.igHtmlEditorPopover,{_init:function(){this.rowsNumField=this.element.find("#"+this._id("_tableRows"));this.columnsNumField=this.element.find("#"+this._id("_tableColumns"));$.ui.igHtmlEditorPopover.prototype._init.apply(this,arguments)},_createForm:function(){var html="
"+'
'+"- "+"
"+"- "+'
'+''+''+"
"+" "+"
"+"
";$(html).appendTo(this.poContent);this._sampleTable=$('
').tableManipulator({rows:8,columns:6}).appendTo(this.poContent.find(".layoutList li:first"))},_attachFormEvents:function(){var tablePreview=this.poContent.find("table"),cells=tablePreview.find("td").addClass("ui-state-default"),rows=tablePreview.find("tr"),self=this;tablePreview.delegate("td","mouseover",function(e){var target=$(e.target),currentRowNumber=target.parent().index()+1,currentColumnNumber=$(this).index()+1,i;cells.removeClass("ui-state-hover");for(i=0;i
';html+=" ";html+=" ";this.poContent.append(html)},_attachFormEvents:function(){var self=this;this.poContent.find("#"+this._id("_btnApply")).igButton({click:function(e){self._item.attr({src:self._imgSrcFld.val(),alt:self._imgAltFld.val()});self._trigger(self.events.apply,e,{image:self._item});self.hide()}}).end().find("#"+this._id("_btnCancel")).igButton({click:function(e){self._trigger(self.events.cancel,e);self.hide()}})},_dataBind:function(image){this._imgSrcFld.val(image.attr("src"));this._imgAltFld.val(image.attr("alt"))}});var table,tableNumRows=0,tableNumCols=0,settings={document:document,rows:0,columns:0,addSpacingChar:false},spacingChar="",methods={init:function(options){return this.each(function(){var tRows;$.extend(settings,options);if(this.nodeName.toLowerCase()!=="table"){return}if(settings.addSpacingChar){spacingChar=" "}table=$(this);tRows=methods.getTableRows();if(settings.rows&&settings.rows>0){tableNumRows=settings.rows}else{tableNumRows=tRows.length}if(settings.columns&&settings.columns>0){tableNumCols=settings.columns}else if(tRows[0]){tableNumCols=tRows[0].cells.length}if(!table.children().length){methods.create()}})},create:function(){var newRow,i,j;table.empty();for(i=0;i