1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615 |
- /**
- * The slideshow dialog definition.
- * Copyright (c) 2003-2013, Cricri042. All rights reserved.
- * Targeted for "ad-gallery" JavaScript : http://adgallery.codeplex.com/
- * And "Fancybox" : http://fancyapps.com/fancybox/
- */
- /**
- * Debug : var_dump
- *
- * @var: Var
- * @level: Level max
- *
- */
- function removeDomainFromUrl(string) {
- "use strict";
- return string.replace(/^https?:\/\/[^\/]+/i, '');
- }
- var IMG_PARAM = {URL:0, TITLE:1, ALT:2, WIDTH:3, HEIGHT:4},
- pluginPath = removeDomainFromUrl(CKEDITOR.plugins.get( 'slideshow' ).path),
- BASE_PATH = removeDomainFromUrl(CKEDITOR.basePath),
- //SCRIPT_JQUERY = "https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js",
- SCRIPT_JQUERY = pluginPath+"3rdParty/jquery.min.js",
- SCRIPT_ADDGAL = pluginPath+"3rdParty/ad-gallery/jquery.ad-gallery.min.js",
- CSS_ADDGAL = pluginPath+"3rdParty/ad-gallery/jquery.ad-gallery.css",
- SCRIPT_FANCYBOX = pluginPath+'3rdParty/fancybox2/jquery.fancybox.pack.js?v=2.1.5',
- CSS_FANCYBOX = pluginPath+"3rdParty/fancybox2/jquery.fancybox.css?v=2.1.5";
- function var_dump(_var, _level) {
- "use strict";
- var dumped_text = "";
- if(!_level) {
- _level = 0;
- }
- //The padding given at the beginning of the line.
- var level_padding = "";
- var j;
- for(j=0; j<_level+1; j+=1) {
- level_padding += " ";
- }
- if(typeof(_var) == 'object') { //Array/Hashes/Objects
- var item;
- var value;
- for(item in _var) {
- if (_var.hasOwnProperty(item)) {
- value = _var[item];
- if(typeof(value) == 'object') { // If it is an array,
- dumped_text += level_padding + "'" + item + "' ...\n";
- dumped_text += var_dump(value, _level+1);
- } else {
- dumped_text += level_padding +"'"+ item +"' => \""+ value +"\"\n";
- }
- }
- }
-
- } else { //Stings/Chars/Numbers etc.
- dumped_text = "===>"+ _var +"<===("+ typeof(_var) +")";
- }
- return dumped_text;
- }
- var listItem = function( node ) {
- "use strict";
- return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'li' );
- };
- var ULItem = function( node ) {
- "use strict";
- return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'ul' );
- };
- var iFrameItem = function( node ) {
- "use strict";
- return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'iframe' );
- };
- Array.prototype.pushUnique = function (item){
- "use strict";
- var i;
- for ( i = 0; i < this.length ; i+=1 ) {
- if (this[i][0] == item[0]) {
- return -1;
- }
- }
- this.push(item);
- return this.length - 1;
- };
- Array.prototype.updateVal = function (item, data){
- "use strict";
- var i;
- for ( i = 0; i < this.length ; i+=1 ) {
- if (this[i][0] == item) {
- this[i] = [item, data];
- return true;
- }
- }
- this[i] = [item, data];
- return false;
- };
- Array.prototype.getVal = function (item){
- "use strict";
- var i;
- for ( i = 0; i < this.length ; i+=1 ) {
- if (this[i][0] == item) {
- return this[i][1];
- }
- }
- return null;
- };
- // Our dialog definition.
- CKEDITOR.dialog.add( 'slideshowDialog', function( editor ) {
- "use strict";
- var lang = editor.lang.slideshow;
- //----------------------------------------------------------------------------------------------------
- // COMBO STUFF
- //----------------------------------------------------------------------------------------------------
- // Add a new option to a CHKBOX object (combo or list).
- function addOption( combo, optionText, optionValue, documentObject, index )
- {
- combo = getSelect( combo );
- var oOption;
- if ( documentObject ) {
- oOption = documentObject.createElement( "OPTION" );
- } else {
- oOption = document.createElement( "OPTION" );
- }
- if ( combo && oOption && oOption.getName() == 'option' )
- {
- if ( CKEDITOR.env.ie ) {
- if ( !isNaN( parseInt( index, 10) ) ) {
- combo.$.options.add( oOption.$, index );
- } else {
- combo.$.options.add( oOption.$ );
- }
- oOption.$.innerHTML = optionText.length > 0 ? optionText : '';
- oOption.$.value = optionValue;
- } else {
- if ( index !== null && index < combo.getChildCount() ) {
- combo.getChild( index < 0 ? 0 : index ).insertBeforeMe( oOption );
- } else {
- combo.append( oOption );
- }
- oOption.setText( optionText.length > 0 ? optionText : '' );
- oOption.setValue( optionValue );
- }
- } else {
- return false;
- }
- return oOption;
- }
-
- // Remove all selected options from a CHKBOX object.
- function removeSelectedOptions( combo )
- {
- combo = getSelect( combo );
- // Save the selected index
- var iSelectedIndex = getSelectedIndex( combo );
- // Remove all selected options.
- var i;
- for ( i = combo.getChildren().count() - 1 ; i >= 0 ; i-=1 )
- {
- if ( combo.getChild( i ).$.selected ) {
- combo.getChild( i ).remove();
- }
- }
- // Reset the selection based on the original selected index.
- setSelectedIndex( combo, iSelectedIndex );
- }
-
- //Modify option from a CHKBOX object.
- function modifyOption( combo, index, title, value )
- {
- combo = getSelect( combo );
- if ( index < 0 ) {
- return false;
- }
- var child = combo.getChild( index );
- child.setText( title );
- child.setValue( value );
- return child;
- }
-
- function removeAllOptions( combo )
- {
- combo = getSelect( combo );
- while ( combo.getChild( 0 ) && combo.getChild( 0 ).remove() )
- { /*jsl:pass*/ }
- }
-
- // Moves the selected option by a number of steps (also negative).
- function changeOptionPosition( combo, steps, documentObject, dialog )
- {
- combo = getSelect( combo );
- var iActualIndex = getSelectedIndex( combo );
- if ( iActualIndex < 0 ) {
- return false;
- }
- var iFinalIndex = iActualIndex + steps;
- iFinalIndex = ( iFinalIndex < 0 ) ? 0 : iFinalIndex;
- iFinalIndex = ( iFinalIndex >= combo.getChildCount() ) ? combo.getChildCount() - 1 : iFinalIndex;
- if ( iActualIndex == iFinalIndex ) {
- return false;
- }
- var re = /(^IMG_\d+)/;
- // Modify sText in final index
- var oOption = combo.getChild( iFinalIndex ),
- sText = oOption.getText(),
- sValue = oOption.getValue();
- sText = sText.replace(re, "IMG_"+iActualIndex);
- modifyOption( combo, iFinalIndex, sText, sValue );
- // do the move
- oOption = combo.getChild( iActualIndex );
- sText = oOption.getText();
- sValue = oOption.getValue();
- oOption.remove();
- // alert(sText+ " / "+ sValue);
- // var result = re.exec(sText);
- sText = sText.replace(re, "IMG_"+iFinalIndex);
- // alert(sText);
- oOption = addOption( combo, sText, sValue, ( !documentObject ) ? null : documentObject, iFinalIndex );
- setSelectedIndex( combo, iFinalIndex );
- // update dialog.imagesList
- var valueActual = dialog.imagesList[iActualIndex];
- var valueFinal = dialog.imagesList[iFinalIndex];
- dialog.imagesList[iActualIndex] = valueFinal;
- dialog.imagesList[iFinalIndex] = valueActual;
- return oOption;
- }
-
- function getSelectedIndex( combo )
- {
- combo = getSelect( combo );
- return combo ? combo.$.selectedIndex : -1;
- }
-
- function setSelectedIndex( combo, index )
- {
- combo = getSelect( combo );
- if ( index < 0 ) {
- return null;
- }
- var count = combo.getChildren().count();
- combo.$.selectedIndex = ( index >= count ) ? ( count - 1 ) : index;
- return combo;
- }
-
- function getOptions( combo )
- {
- combo = getSelect( combo );
- return combo ? combo.getChildren() : false;
- }
-
- function getSelect( obj )
- {
- if ( obj && obj.domId && obj.getInputElement().$ ) {
- return obj.getInputElement();
- } else if ( obj && obj.$ ) {
- return obj;
- }
- return false;
- }
- function unselectAll(dialog) {
- var editBtn = dialog.getContentElement( 'slideshowinfoid', 'editselectedbtn');
- var deleteBtn = dialog.getContentElement( 'slideshowinfoid', 'removeselectedbtn');
- editBtn = getSelect( editBtn );
- editBtn.hide();
- deleteBtn = getSelect( deleteBtn );
- deleteBtn.hide();
- var comboList = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- comboList = getSelect( comboList );
- var i;
- for ( i = comboList.getChildren().count() - 1 ; i >= 0 ; i-=1 )
- {
- comboList.getChild( i ).$.selected = false;
- }
- }
- function unselectIfNotUnique(combo) {
- var dialog = combo.getDialog();
- var selectefItem = null;
- combo = getSelect( combo );
- var cnt = 0;
- var editBtn = dialog.getContentElement( 'slideshowinfoid', 'editselectedbtn');
- var deleteBtn = dialog.getContentElement( 'slideshowinfoid', 'removeselectedbtn');
- var i, child;
- for ( i = combo.getChildren().count() - 1 ; i >= 0 ; i-=1 )
- {
- child = combo.getChild( i );
- if ( child.$.selected ) {
- cnt++;
- selectefItem = child;
- }
- }
- if (cnt > 1) {
- unselectAll(dialog);
- return null;
- } else if (cnt == 1) {
- editBtn = getSelect( editBtn );
- editBtn.show();
- deleteBtn = getSelect( deleteBtn );
- deleteBtn.show();
- displaySelected(dialog);
- return selectefItem;
- }
- return null;
- }
- function displaySelected (dialog) {
- if (dialog.openCloseStep == true) {
- return;
- }
- var previewCombo = dialog.getContentElement( 'slideshowinfoid', 'framepreviewid');
- if ( previewCombo.isVisible()) {
- previewSlideShow(dialog);
- } else {
- editeSelected(dialog);
- }
- }
- function selectFirstIfNotUnique(combo) {
- var dialog = combo.getDialog();
- combo = getSelect( combo );
- var firstSelectedInd = 0;
- var i, child, selectefItem;
- for ( i = 0; i < combo.getChildren().count() ; i+=1 )
- {
- child = combo.getChild( i );
- if ( child.$.selected ) {
- selectefItem = child;
- firstSelectedInd = i;
- break;
- }
- }
- setSelectedIndex(combo, firstSelectedInd);
- displaySelected(dialog);
- }
- function getSlectedIndex(dialog) {
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- return getSelectedIndex( combo );
- }
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- function removePlaceHolderImg(dialog) {
- var urlPlaceHolder = BASE_PATH + 'plugins/slideshow/images/placeholder.png' ;
- if ((dialog.imagesList.length == 1) && (dialog.imagesList[0][IMG_PARAM.URL] == urlPlaceHolder)) {
- // Remove the place Holder Image
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- combo = getSelect( combo );
- var i = 0;
- // Remove image from image Array
- dialog.imagesList.splice(i, 1);
- // Remove image from combo image list
- combo.getChild( i ).remove();
- }
- }
- function updateImgList(dialog) {
- removePlaceHolderImg(dialog);
- var preview = dialog.previewImage;
- var url = preview.$.src;
- var ratio = preview.$.width / preview.$.height;
- var w = 50;
- var h = 50;
- if (ratio > 1) {
- h = h/ratio;
- } else {
- w = w*ratio;
- }
- var oOption;
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- var ind = dialog.imagesList.pushUnique([url, '', '', w.toFixed(0), h.toFixed(0)]);
- if (ind >= 0) {
- oOption = addOption( combo, 'IMG_'+ind + ' : ' + url.substring(url.lastIndexOf('/')+1), url, dialog.getParentEditor().document );
- // select index 0
- setSelectedIndex(combo, ind);
- // Update dialog
- displaySelected(dialog);
- }
- }
- function editeSelected(dialog) {
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- var iSelectedIndex = getSelectedIndex( combo );
- var value = dialog.imagesList[iSelectedIndex];
- combo = dialog.getContentElement( 'slideshowinfoid', 'imgtitleid');
- combo = getSelect( combo );
- combo.setValue(value[1]);
- combo = dialog.getContentElement( 'slideshowinfoid', 'imgdescid');
- combo = getSelect( combo );
- combo.setValue(value[2]);
- combo = dialog.getContentElement( 'slideshowinfoid', 'imgpreviewid');
- combo = getSelect( combo );
- //console.log( "VALUE IMG -> " + value[iSelectedIndex] );
- var imgHtml = '<div style="text-align:center;"> <img src="'+ value[0] +
- '" title="' + value[1] +
- '" alt="' + value[2] +
- '" style=" max-height: 200px; max-width: 350px;' + '"> </div>';
- combo.setHtml(imgHtml);
- var previewCombo = dialog.getContentElement( 'slideshowinfoid', 'framepreviewid');
- var imgCombo = dialog.getContentElement( 'slideshowinfoid', 'imgparamsid');
- previewCombo = getSelect( previewCombo );
- previewCombo.hide();
- imgCombo = getSelect( imgCombo );
- imgCombo.show();
- }
- function removeSelected(dialog) {
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- combo = getSelect( combo );
- var someRemoved = false;
- // Remove all selected options.
- var i;
- for ( i = combo.getChildren().count() - 1 ; i >= 0 ; i-- )
- {
- if ( combo.getChild( i ).$.selected ) {
- // Remove image from image Array
- dialog.imagesList.splice(i, 1);
- // Remove image from combo image list
- combo.getChild( i ).remove();
- someRemoved = true;
- }
- }
- if (someRemoved) {
- if (dialog.imagesList.length == 0) {
- var url = BASE_PATH + 'plugins/slideshow/images/placeholder.png' ;
- var oOption = addOption( combo, 'IMG_0' + ' : ' + url.substring(url.lastIndexOf('/')+1) , url, dialog.getParentEditor().document );
- dialog.imagesList.pushUnique([url, lang.imgTitle, lang.imgDesc, '50', '50']);
- }
- // select index 0
- setSelectedIndex(combo, 0);
- // Update dialog
- displaySelected(dialog);
- }
- }
- function upDownSelected(dialog, offset) {
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- combo = getSelect( combo );
- var iSelectedIndex = getSelectedIndex( combo );
- if (combo.getChildren().count() == 1) {
- return;
- }
- if ((offset == -1) && (iSelectedIndex == 0)) {
- return;
- }
- if ((offset == 1) && (iSelectedIndex == combo.getChildren().count()-1)) {
- return;
- }
- //alert(iSelectedIndex+" / "+combo.getChildren().count() + " / "+ offset);
- changeOptionPosition( combo, offset, dialog.getParentEditor().document, dialog );
- updateFramePreview(dialog);
- }
-
- // To automatically get the dimensions of the poster image
- var onImgLoadEvent = function() {
- // Image is ready.
- var preview = this.previewImage;
- preview.removeListener( 'load', onImgLoadEvent );
- preview.removeListener( 'error', onImgLoadErrorEvent );
- preview.removeListener( 'abort', onImgLoadErrorEvent );
- //console.log( "previewImage -> " + preview );
- updateImgList(this);
- };
- var onImgLoadErrorEvent = function() {
- // Error. Image is not loaded.
- var preview = this.previewImage;
- preview.removeListener( 'load', onImgLoadEvent );
- preview.removeListener( 'error', onImgLoadErrorEvent );
- preview.removeListener( 'abort', onImgLoadErrorEvent );
- };
- function updateTitle(dialog, val) {
- dialog.imagesList[getSlectedIndex(dialog)][IMG_PARAM.TITLE] = val;
- editeSelected(dialog);
- }
- function updateDescription(dialog, val) {
- dialog.imagesList[getSlectedIndex(dialog)][IMG_PARAM.ALT] = val;
- editeSelected(dialog);
- }
- function previewSlideShow(dialog) {
- var previewCombo = dialog.getContentElement( 'slideshowinfoid', 'framepreviewid');
- var imgCombo = dialog.getContentElement( 'slideshowinfoid', 'imgparamsid');
- imgCombo = getSelect( imgCombo );
- imgCombo.hide();
- previewCombo = getSelect( previewCombo );
- previewCombo.show();
- updateFramePreview(dialog);
- }
- function feedFrame(frame, data) {
- frame.open();
- frame.writeln( data );
- frame.close();
- }
- // function unprotectRealComments( html )
- // {
- // return html.replace( /<!--\{cke_protected\}\{C\}([\s\S]+?)-->/g,
- // function( match, data )
- // {
- // return decodeURIComponent( data );
- // });
- // };
- //
- // function unprotectSource( html, editor )
- // {
- // return html.replace( /<!--\{cke_protected\}([\s\S]+?)-->/g, function( match, data )
- // {
- // return decodeURIComponent( data );
- // });
- // }
- function updateFramePreview(dialog) {
- var width = 436;
- var height = 300;
- if ( dialog.params.getVal('showthumbid') == true) {
- height -= 120;
- } else if ( dialog.params.getVal('showcontrolid') == true) {
- height -= 30;
- }
- if (dialog.imagesList.length == 0) {
- return;
- }
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- var iSelectedIndex = getSelectedIndex( combo );
- if (iSelectedIndex < 0) {
- iSelectedIndex = 0;
- }
-
- combo = dialog.getContentElement( 'slideshowinfoid', 'framepreviewid');
-
- var strVar="";
- var jqueryStr = '<script src="'+SCRIPT_JQUERY+'" type="text/javascript"></script>';
- strVar += "<head>";
- // if (editor.config.slideshowDoNotLoadJquery && (editor.config.slideshowDoNotLoadJquery == true)) {
- // jqueryStr = '';
- // }
- strVar += jqueryStr;
- strVar += "<script type=\"text\/javascript\" src=\""+SCRIPT_ADDGAL+"\"><\/script>";
- strVar += "<link rel=\"stylesheet\" type=\"text\/css\" href=\""+CSS_ADDGAL+"\" \/>";
- if ( dialog.params.getVal('openOnClickId') == true) {
- strVar += "<link rel=\"stylesheet\" type=\"text\/css\" href=\""+CSS_FANCYBOX+"\" \/>";
- strVar += "<script type=\"text\/javascript\" src=\""+SCRIPT_FANCYBOX+"\"><\/script>";
- strVar += "<script type=\"text\/javascript\">";
- strVar += createScriptFancyBoxRun(dialog);
- strVar += "<\/script>";
- }
- strVar += "<script type=\"text\/javascript\">";
- strVar += createScriptAdGalleryRun(dialog, iSelectedIndex, width, height);
- strVar += "<\/script>";
- strVar += "<\/head>";
- strVar += "<body>";
- var domGallery = createDOMdGalleryRun(dialog);
- strVar += domGallery.getOuterHtml();
- strVar += "<\/body>";
- strVar += "";
- combo = getSelect( combo );
- var theFrame = combo.getFirst( iFrameItem );
- if (theFrame) {
- theFrame.remove();
- }
- var ifr = null;
- var w = width+60;
- var h = height;
-
- if ( dialog.params.getVal('showthumbid') == true) {
- h += 120;
- } else if ( dialog.params.getVal('showcontrolid') == true) {
- h += 30;
- }
- var iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
- ' style="width:'+w+'px;height:'+h+'px;background:azure; "'+
- ' class="cke_pasteframe"' +
- ' frameborder="10" ' +
- ' allowTransparency="false"' +
- // ' src="' + 'data:text/html;charset=utf-8,' + strVar + '"' +
- ' role="region"' +
- ' scrolling="no"' +
- '></iframe>' );
- iframe.setAttribute('name', 'totoFrame');
- iframe.setAttribute('id', 'totoFrame');
- iframe.on( 'load', function( event ) {
- if (ifr != null) {
- return;
- }
- ifr = this.$;
- var iframedoc;
- if (ifr.contentDocument) {
- iframedoc = ifr.contentDocument;
- } else if (ifr.contentWindow) {
- iframedoc = ifr.contentWindow.document;
- }
-
- if (iframedoc){
- // Put the content in the iframe
- feedFrame(iframedoc, strVar);
- } else {
- //just in case of browsers that don't support the above 3 properties.
- //fortunately we don't come across such case so far.
- alert('Cannot inject dynamic contents into iframe.');
- }
- });
- combo.append(iframe);
- }
- function initImgListFromDOM(dialog, slideShowContainer) {
- var i, image, src;
- var imgW, imgH;
- var ratio, w, h, ind;
- var arr = slideShowContainer.$.getElementsByTagName("img");
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- for (i = 0; i < arr.length; i+=1) {
- image = arr[i];
- src = image.src;
- // IE Seems sometime to return 0 !!, So natural Width and Height seems OK
- // If not just pput 50, Not as good but not so bad !!
- imgW = image.width;
- if (imgW == 0) {
- imgW = image.naturalWidth;
- }
- if (imgW == 0) {
- imgW = 50;
- imgH = 50;
- } else {
- imgH = image.height;
- if (imgH == 0) {
- imgH = image.naturalHeight;
- }
- if (imgH == 0) {
- imgW = 50;
- imgH = 50;
- }
- }
- ratio = imgW / imgH;
- w = 50;
- h = 50;
- if (ratio > 1) {
- h = h/ratio;
- } else {
- w = w*ratio;
- }
- ind = dialog.imagesList.pushUnique([src, image.title, image.alt, w, h]);
- var oOption;
- if (ind >= 0) {
- oOption = addOption( combo, 'IMG_'+ind + ' : ' + src.substring(src.lastIndexOf('/')+1), src, dialog.getParentEditor().document );
- }
- }
- // select index 0
- setSelectedIndex(combo, 0);
- // Update dialog
- displaySelected(dialog);
- }
- function initImgListFromFresh(dialog) {
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- var url = BASE_PATH + 'plugins/slideshow/images/placeholder.png' ;
- var oOption = addOption( combo, 'IMG_0' + ' : ' + url.substring(url.lastIndexOf('/')+1) , url, dialog.getParentEditor().document );
- dialog.imagesList.pushUnique([url, lang.imgTitle, lang.imgDesc, '50', '50']);
- // select index 0
- setSelectedIndex(combo, 0);
- // Update dialog
- displaySelected(dialog);
- }
- function commitSlideShow(dialog) {
- dialog.slideshowDOM.setAttribute('data-'+this.id, this.getValue());
- }
- function loadValue() {
- var dialog = this.getDialog();
- if (dialog.newSlideShowMode) {
- // New fresh SlideShow so let's put dom data attributes from dialog default values
- dialog.slideshowDOM.setAttribute('data-'+this.id, this.getValue());
- switch ( this.type ) {
- case 'checkbox':
- break;
- case 'text':
- break;
- case 'select':
- break;
- default:
- break;
- }
- } else {
- // Loaded SlideShow, so update Dialog values from DOM data attributes
- switch ( this.type ) {
- case 'checkbox':
- this.setValue(dialog.slideshowDOM.getAttribute('data-'+this.id) == 'true');
- break;
- case 'text':
- this.setValue(dialog.slideshowDOM.getAttribute('data-'+this.id));
- break;
- case 'select':
- this.setValue(dialog.slideshowDOM.getAttribute('data-'+this.id));
- break;
- default:
- break;
- }
- }
- }
- function commitValue() {
- var dialog = this.getDialog();
- dialog.params.updateVal(this.id, this.getValue());
- switch ( this.type ) {
- case 'checkbox':
- break;
- case 'text':
- break;
- case 'select':
- break;
- default:
- break;
- }
- displaySelected(dialog);
- }
- function cleanAll(dialog) {
- if ( dialog.previewImage )
- {
- dialog.previewImage.removeListener( 'load', onImgLoadEvent );
- dialog.previewImage.removeListener( 'error', onImgLoadErrorEvent );
- dialog.previewImage.removeListener( 'abort', onImgLoadErrorEvent );
- dialog.previewImage.remove();
- dialog.previewImage = null; // Dialog is closed.
- }
- dialog.imagesList = null;
- dialog.params = null;
- dialog.slideshowDOM = null;
- var combo = dialog.getContentElement( 'slideshowinfoid', 'imglistitemsid');
- removeAllOptions(combo);
- dialog.openCloseStep = false;
- }
- function randomChars(len) {
- var chars = '';
- while (chars.length < len) {
- chars += Math.random().toString(36).substring(2);
- }
- // Remove unnecessary additional characters.
- return chars.substring(0, len);
- }
- var numbering = function( id ) {
- //return CKEDITOR.tools.getNextId() + '_' + id;
- return 'cke_' + randomChars(8) + '_' + id;
- };
- function getImagesContainerBlock(dialog, dom) {
- var obj = dom.getElementsByTag("ul");
- if (obj == null) {
- return null;
- }
- if (obj.count() == 1) {
- return obj.getItem(0);
- }
- return null;
- }
- function createScriptAdGalleryRun(dialog, iSelectedIndex, width, height) {
- var slideshowid = dialog.params.getVal('slideshowid'),
- galleryId = 'ad-gallery_' + slideshowid,
- strVar = '(function($) {',
- strHook = '';
-
- strVar += "$(function() {";
- // if (width == 0) width = "false";
- if (height == 0) {
- height = dialog.params.getVal('pictheightid');
- }
- // if (width == 0) width = dialog.params.getVal('pictWidthtid');
- // if (height == 0) height = "false";
- // if (width <= 1) width = "false";
- if (width == 0) {
- width = "false";
- }
- if (dialog.params.getVal('showtitleid') == false) {
- strHook = ", hooks: { displayDescription: function(image) {}}";
- }
- var params = "loader_image: '"+pluginPath+"3rdParty/ad-gallery/loader.gif'," +
- " width:" + width + ", height:" + height +
- ", start_at_index: " + iSelectedIndex +
- ", animation_speed: " + dialog.params.getVal('animspeedid') + strHook +
- ", update_window_hash: false, effect: '" + dialog.params.getVal('transitiontypeid') +
- "',";
- //alert(params);
- var slideShowParams = " slideshow: { enable: true, autostart: " + dialog.params.getVal('autostartid') +
- ", start_label: '" + lang.labelStart + "'" +
- ", stop_label: '" + lang.labelStop + "'" +
- ", speed: " + dialog.params.getVal('speedid') * 1000 +
- "}";
- strVar += " var galleries = $('#"+galleryId+"').adGallery({" + params + slideShowParams + "});";
- strVar += "});";
- strVar += "})(jQuery);";
- return strVar;
- }
- // function createScriptFancyBoxRun(dialog) {
- // var slideshowid = dialog.params.getVal('slideshowid'),
- // galleryId = 'ad-gallery_' + slideshowid,
- // str = '(function($) {';
- //// str += "$(document).ready(function() {";
- // str += "$(function() {";
- // str += "$(\"#"+galleryId+"\").on(\"click\",\".ad-image\",function(){";
- // str += "var imgObj =$(this).find(\"img\");";
- // str += "var isrc=imgObj.attr(\"src\");";
- // str += "var ititle=null;";
- // str += "var idesc=null;";
- // str += "var iname=isrc.split('/');";
- // str += "iname=iname[iname.length-1];";
- // str += "var imgdescid=$(this).find(\".ad-image-description\");";
- // str += "if(imgdescid){";
- // str += "ititle=$(this).find(\".ad-description-title\");";
- // str += "if(ititle)ititle=ititle.text();";
- // str += "if(ititle!='')ititle='<big>'+ititle+'</big>';";
- // str += "idesc=$(this).find(\"span\");";
- // str += "if(idesc)idesc=idesc.text();";
- // str += "if(idesc!=''){";
- // str += "if(ititle!='')ititle=ititle+'<br>';";
- // str += "idesc='<i>'+idesc+'</i>';";
- // str += "}";
- // str += "}";
- // str += "$.fancybox.open({";
- // str += "href:isrc,";
- // str += "beforeLoad:function(){";
- // str += "this.title=ititle+idesc;";
- // str += "},";
- // str += "});";
- // str += "});";
- // str += "});";
- // str += "})(jQuery);";
- //
- // return str;
- // }
- function createScriptFancyBoxRun(dialog) {
- var slideshowid = dialog.params.getVal('slideshowid'),
- galleryId = 'ad-gallery_' + slideshowid,
- str = '(function($) {';
- str += "$(function() {";
- str += "$(\"#"+galleryId+"\").on(\"click\",\".ad-image\",function(){";
- str += "var imgObj =$(this).find(\"img\");";
- str += "var isrc=imgObj.attr(\"src\");";
- str += "var ititle=null;";
- str += "var idesc=null;";
- str += "var iname=isrc.split('/');";
- str += "iname=iname[iname.length-1];";
- str += "var imgdescid=$(this).find(\".ad-image-description\");";
- str += "if(imgdescid){";
- str += "ititle=$(this).find(\".ad-description-title\");";
- str += "if(ititle)ititle=ititle.text();";
- str += "if(ititle!='')ititle='<big>'+ititle+'</big>';";
- str += "idesc=$(this).find(\"span\");";
- str += "if(idesc)idesc=idesc.text();";
- // str += 'console.log("idesc:", idesc);';
- str += "if (idesc.indexOf('IMAGE_LINK_') >= 0) {";
- str += "idesc = '';";
- str += "}";
- str += "if(idesc!=''){";
- str += "if(ititle!='')ititle=ititle+'<br>';";
- str += "idesc='<i>'+idesc+'</i>';";
- str += "}";
- str += "}";
- str += "$.fancybox.open({";
- str += "href:isrc,";
- str += "beforeLoad:function(){";
- str += "this.title=ititle+idesc;";
- str += "},";
- str += "});";
- str += "});";
- str += "});";
- str += "})(jQuery);";
- return str;
- }
- function createScriptLinkRun(dialog) {
- var slideshowid = dialog.params.getVal('slideshowid'),
- galleryId = 'ad-gallery_' + slideshowid,
- str = '(function($) {';
- str += "$(function() {";
- str += "$(\"#"+galleryId+"\").on(\"click\",\".ad-image\",function(){";
- str += "var imgObj =$(this).find(\"img\");";
- str += "var isrc=imgObj.attr(\"src\");";
- str += "var ititle=null;";
- str += "var idesc=null;";
- str += "var iname=isrc.split('/');";
- str += "iname=iname[iname.length-1];";
- str += "var imgdescid=$(this).find(\".ad-image-description\");";
- str += "if(imgdescid){";
- str += "ititle=$(this).find(\".ad-description-title\");";
- str += "if(ititle)ititle=ititle.text();";
- str += "idesc=$(this).find(\"span\");";
- // str += "console.log('desc0', idesc);";
- str += "if(idesc)idesc=idesc.text();";
- str += "if(idesc!=''){";
- // str += "console.log('desc1', idesc);";
-
- // str += "if (idesc.indexOf('LIEN:') == 0) {";
- // str += "idesc = idesc.substring(5);}";
- // str += "window.open(idesc);"
- // str += "}";
- str += "var url=window.location.href.trim();";
- str += "if (idesc.indexOf('IMAGE_LINK_TAB:') >= 0) {";
- str += " idesc = idesc.substring(15).trim();";
- str += " if (url != idesc) window.open(idesc,'_blank');";
- str += "} else if (idesc.indexOf('IMAGE_LINK_PAR:') >= 0) {";
- str += " idesc = idesc.substring(15).trim();";
- str += " if (url != idesc) window.open(idesc,'_self');";
- str += "}";
-
- str += "}";
- str += "}";
- str += "});";
- str += "});";
- str += "})(jQuery);";
- return str;
- }
- function feedUlWithImages(dialog, ulObj) {
- var i, liObj, aObj, newImgDOM;
- for ( i = 0; i < dialog.imagesList.length ; i+=1 ) {
- liObj = ulObj.append( 'li' );
- liObj.setAttribute( 'contenteditable', 'false');
- aObj = liObj.append( 'a' );
- aObj.setAttribute( 'href', removeDomainFromUrl(dialog.imagesList[i][IMG_PARAM.URL]) );
- aObj.setAttribute('contenteditable', 'false');
- newImgDOM = aObj.append('img');
- newImgDOM.setAttribute( 'src', removeDomainFromUrl(dialog.imagesList[i][IMG_PARAM.URL]) );
- newImgDOM.setAttribute( 'title', dialog.imagesList[i][IMG_PARAM.TITLE]);
- newImgDOM.setAttribute( 'alt', dialog.imagesList[i][IMG_PARAM.ALT]);
- newImgDOM.setAttribute( 'contenteditable', 'false');
- newImgDOM.setAttribute('width', dialog.imagesList[i][IMG_PARAM.WIDTH]);
- newImgDOM.setAttribute('height', dialog.imagesList[i][IMG_PARAM.HEIGHT]);
- }
- }
- function createDOMdGalleryRun(dialog) {
- var slideshowid = dialog.params.getVal('slideshowid');
- var galleryId = 'ad-gallery_' + slideshowid;
- var displayThumbs = 'display: block;';
- var displayControls = 'display: block;';
- if ( dialog.params.getVal('showthumbid') == false) {
- displayThumbs = 'display: none;';
- }
- if ( dialog.params.getVal('showcontrolid') == false) {
- displayControls = 'visibility: hidden;';
- }
- var slideshowDOM = editor.document.createElement( 'div' );
- slideshowDOM.setAttribute('id', slideshowid );
- slideshowDOM.setAttribute( 'class', 'slideshowPlugin');
- slideshowDOM.setAttribute( 'contenteditable', 'false');
- var galleryDiv = slideshowDOM.append('div');
- galleryDiv.setAttribute( 'class', 'ad-gallery');
- galleryDiv.setAttribute( 'contenteditable', 'false');
- galleryDiv.setAttribute( 'id', galleryId);
- var wrapperObj = galleryDiv.append('div');
- wrapperObj.setAttribute( 'class', 'ad-image-wrapper');
- wrapperObj.setAttribute( 'contenteditable', 'false');
- var controlObj = galleryDiv.append('div');
- controlObj.setAttribute( 'class', 'ad-controls');
- controlObj.setAttribute( 'contenteditable', 'false');
- controlObj.setAttribute( 'style', displayControls);
- var navObj = galleryDiv.append('div');
- navObj.setAttribute( 'class', 'ad-nav');
- navObj.setAttribute( 'style', displayThumbs);
- navObj.setAttribute( 'contenteditable', 'false');
- var thumbsObj = navObj.append('div');
- thumbsObj.setAttribute( 'class', 'ad-thumbs');
- thumbsObj.setAttribute( 'contenteditable', 'false');
- var ulObj = thumbsObj.append('ul');
- ulObj.setAttribute('class', 'ad-thumb-list');
- ulObj.setAttribute( 'contenteditable', 'false');
- feedUlWithImages(dialog, ulObj);
- return slideshowDOM;
- }
- function ClickOkBtn(dialog) {
- var extraStyles = {},
- extraAttributes = {};
- dialog.openCloseStep = true;
- // Invoke the commit methods of all dialog elements, so the dialog.params array get Updated.
- dialog.commitContent(dialog);
- // Create a new DOM
- var slideshowDOM = createDOMdGalleryRun(dialog);
- // Add data tags to dom
- var i;
- for ( i = 0; i < dialog.params.length ; i+=1 ) {
- slideshowDOM.data(dialog.params[i][0], dialog.params[i][1]);
- }
- if (!(editor.config.slideshowDoNotLoadJquery && (editor.config.slideshowDoNotLoadJquery == true))) {
- var scriptjQuery = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript',
- src: SCRIPT_JQUERY
- }
- });
- slideshowDOM.append(scriptjQuery);
- }
- // Add javascript for ""ad-gallery"
- // Be sure the path is correct and file is available !!
- var scriptAdGallery = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript',
- src: SCRIPT_ADDGAL
- }
- });
- slideshowDOM.append(scriptAdGallery);
- if ( dialog.params.getVal('openOnClickId') == true) {
- // Dynamically add CSS for "fancyBox"
- // Be sure the path is correct and file is available !!
- var scriptFancyBoxCss = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript'
- }
- });
- scriptFancyBoxCss.setText("(function($) { $('head').append('<link rel=\"stylesheet\" href=\""+CSS_FANCYBOX+"\" type=\"text/css\" />'); })(jQuery);");
- slideshowDOM.append(scriptFancyBoxCss);
- // Add javascript for ""fancyBox"
- // Be sure the path is correct and file is available !!
- var scriptFancyBox = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript',
- src: SCRIPT_FANCYBOX
- }
- });
- slideshowDOM.append(scriptFancyBox);
- // Add RUN javascript for "fancybox"
- var scriptFancyboxRun = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript'
- }
- });
- scriptFancyboxRun.setText(createScriptFancyBoxRun(dialog));
- slideshowDOM.append(scriptFancyboxRun);
- }
- // Add RUN javascript for "link"
- var scriptLinkRun = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript'
- }
- });
- scriptLinkRun.setText(createScriptLinkRun(dialog));
- slideshowDOM.append(scriptLinkRun);
- // Dynamically add CSS for "ad-gallery"
- // Be sure the path is correct and file is available !!
- var scriptAdGalleryCss = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript'
- }
- });
- scriptAdGalleryCss.setText("(function($) { $('head').append('<link rel=\"stylesheet\" href=\""+CSS_ADDGAL+"\" type=\"text/css\" />'); })(jQuery);");
- slideshowDOM.append(scriptAdGalleryCss);
- // Add RUN javascript for "ad-Gallery"
- var scriptAdGalleryRun = CKEDITOR.document.createElement( 'script', {
- attributes: {
- type: 'text/javascript'
- }
- });
- scriptAdGalleryRun.setText(createScriptAdGalleryRun(dialog, 0, 0, 0));
- slideshowDOM.append(scriptAdGalleryRun);
- if (dialog.imagesList.length) {
- extraStyles.backgroundImage = 'url("' + dialog.imagesList[0][IMG_PARAM.URL] + '")';
- }
- extraStyles.backgroundSize = '50%';
- extraStyles.display = 'block';
- // Create a new Fake Image
- var newFakeImage = editor.createFakeElement( slideshowDOM, 'cke_slideShow', 'slideShow', false );
- newFakeImage.setAttributes( extraAttributes );
- newFakeImage.setStyles( extraStyles );
- if ( dialog.fakeImage )
- {
- newFakeImage.replace( dialog.fakeImage );
- editor.getSelection().selectElement( newFakeImage );
- }
- else
- {
- editor.insertElement( newFakeImage );
- }
- cleanAll(dialog);
- dialog.hide();
- return true;
- }
- return {
- // Basic properties of the dialog window: title, minimum size.
- title : lang.dialogTitle,
- width: 500,
- height: 600,
- resizable: CKEDITOR.DIALOG_RESIZE_NONE,
- buttons: [
- CKEDITOR.dialog.okButton( editor, {
- label: 'OkCK',
- style : 'display:none;'
- }),
- CKEDITOR.dialog.cancelButton,
- {
- id: 'myokbtnid',
- type: 'button',
- label: 'OK',
- title: lang.validModif,
- accessKey: 'C',
- disabled: false,
- onClick: function()
- {
- // code on click
- ClickOkBtn(this.getDialog());
- }
- }
- ],
- // Dialog window contents definition.
- contents: [
- {
- // Definition of the Basic Settings dialog (page).
- id: 'slideshowinfoid',
- label: 'Basic Settings',
- align : 'center',
- // The tab contents.
- elements: [
- {
- type : 'text',
- id : 'id',
- style : 'display:none;',
- onLoad : function()
- {
- this.getInputElement().setAttribute( 'readOnly', true );
- }
- },
- {
- type: 'text',
- id: 'txturlid',
- style : 'display:none;',
- label: lang.imgList,
- onChange: function() {
- var dialog = this.getDialog(),
- newUrl = this.getValue();
- if ( newUrl.length > 0 ) { //Prevent from load before onShow
- var preview = dialog.previewImage;
- preview.on( 'load', onImgLoadEvent, dialog );
- preview.on( 'error', onImgLoadErrorEvent, dialog );
- preview.on( 'abort', onImgLoadErrorEvent, dialog );
- preview.setAttribute( 'src', newUrl );
- }
- }
- },
- {
- type : 'button',
- id : 'browse',
- hidden : 'true',
- style : 'display:inline-block;margin-top:0px;',
- filebrowser :
- {
- action : 'Browse',
- target: 'slideshowinfoid:txturlid',
- url: editor.config.filebrowserImageBrowseUrl || editor.config.filebrowserBrowseUrl
- },
- label : lang.imgAdd
- },
- // {
- // type : 'button',
- // id : 'browseDir',
- // style : 'display:inline-block;margin-top:0px;',
- // label : "toto",
- // onClick : function() {
- // previewSlideShow(this.getDialog());
- // }
- // },
- {
- type: 'vbox',
- align: 'center',
- children: [
- {
- type: 'html',
- align : 'center',
- id: 'framepreviewtitleid',
- style: 'font-family: Amaranth; color: #1E66EB; font-size: 20px; font-weight: bold;',
- html: lang.previewMode
- },
- {
- type: 'html',
- id: 'framepreviewid',
- align : 'center',
- style : 'width:500px;height:320px',
- html: ''
- },
- {
- type: 'hbox',
- id: 'imgparamsid',
- style : 'display:none;width:500px;',
- height: '325px',
- children :
- [
- {
- type : 'vbox',
- align : 'center',
- width : '400px',
- children :
- [
- {
- type : 'text',
- id : 'imgtitleid',
- label : lang.imgTitle,
- onChange: function() {
- updateTitle(this.getDialog(), this.getValue());
- },
- onBlur: function() {
- updateTitle(this.getDialog(), this.getValue());
- }
- },
- {
- type : 'text',
- id : 'imgdescid',
- label : lang.imgDesc,
- onChange: function() {
- updateDescription(this.getDialog(), this.getValue());
- },
- onBlur: function() {
- updateDescription(this.getDialog(), this.getValue());
- }
- },
- {
- type : 'html',
- id : 'imgpreviewid',
- style : 'width:400px;height:200px;',
- html: '<div>xx</div>'
- }
- ]
- }
- ]
- },
- {
- type : 'hbox',
- align: 'center',
- height: 110,
- widths: [ '25%', '50%'],
- children :
- [
- {
- type : 'vbox',
- children :
- [
- {
- type : 'checkbox',
- id : 'autostartid',
- label : lang.autoStart,
- 'default' : 'checked',
- style : 'margin-top:15px;',
- onChange : commitValue,
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'checkbox',
- id : 'showtitleid',
- label : lang.showTitle,
- 'default' : 'checked',
- onChange : commitValue,
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'checkbox',
- id : 'showcontrolid',
- label : lang.showControls,
- 'default' : 'checked',
- onChange : commitValue,
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'checkbox',
- id : 'showthumbid',
- label : lang.showThumbs,
- 'default' : 'checked',
- onChange : commitValue,
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'checkbox',
- id : 'openOnClickId',
- label : lang.openOnClick,
- 'default' : 'checked',
- onChange : commitValue,
- commit : commitValue,
- setup : loadValue
- }
- ]
- },
- {
- type: 'select',
- id: 'imglistitemsid',
- label: lang.picturesList,
- multiple: false,
- style : 'height:125px;width:250px',
- items: [],
- onChange : function( api ) {
- //unselectIfNotUnique(this);
- selectFirstIfNotUnique(this);
- }
- },
- {
- type : 'vbox',
- children :
- [
- {
- type : 'button',
- id : 'previewbtn',
- style : 'margin-top:15px;margin-left:25px;',
- label : lang.previewMode,
- onClick : function() {
- previewSlideShow(this.getDialog());
- }
- },
- {
- type : 'button',
- id : 'removeselectedbtn',
- style : 'margin-left:25px;',
- //style : 'display:none;',
- label : lang.imgDelete,
- onClick : function() {
- removeSelected(this.getDialog());
- }
- },
- {
- type : 'button',
- id : 'editselectedbtn',
- style : 'margin-left:25px;',
- //style : 'display:none;',
- label : lang.imgEdit,
- onClick : function() {
- editeSelected(this.getDialog());
- }
- },
- {
- type : 'hbox',
- children :
- [
- {
- type : 'button',
- id : 'upselectedbtn',
- style : 'width:32px; margin-left:25px;',
- //style : 'display:none;',
- label : lang.arrowUp,
- onClick : function() {
- upDownSelected(this.getDialog(), -1);
- }
- },
- {
- type : 'button',
- id : 'downselectedbtn',
- style : 'width:32px;',
- //style : 'margin-left:5px;',
- //style : 'display:none;',
- label : lang.arrowDown,
- onClick : function() {
- upDownSelected(this.getDialog(), 1);
- }
- }
- ]
- }
- ]
- }
- ]
- },
- {
- type : 'hbox',
- children :
- [
- // {
- // type : 'text',
- // id : 'pictWidthtid',
- // label : lang.pictWidth,
- // maxLength : 3,
- // style : 'width:100px;',
- // 'default' : '300',
- // onChange : function( api ) {
- // var intRegex = /^\d+$/;
- // if(intRegex.test(this.getValue()) == false) {
- // console.log("setValue0: ", this.getValue());
- // this.setValue(300);
- // } else {
- // console.log("setValue1: ", this.getValue());
- // }
- // this.getDialog().params.updateVal(this.id, this.getValue());
- // displaySelected(this.getDialog());
- // },
- // commit : commitValue,
- // setup : loadValue,
- // },
- {
- type : 'text',
- id : 'pictheightid',
- label : lang.pictHeight,
- maxLength : 3,
- style : 'width:100px;',
- 'default' : '300',
- onChange : function( api ) {
- var intRegex = /^\d+$/;
- if(intRegex.test(this.getValue()) == false) {
- this.setValue(300);
- }
- this.getDialog().params.updateVal(this.id, this.getValue());
- displaySelected(this.getDialog());
- },
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'text',
- id : 'speedid',
- label : lang.displayTime,
- maxLength : 3,
- style : 'width:100px;',
- 'default' : '5',
- onChange : function( api ) {
- var intRegex = /^\d+$/;
- if(intRegex.test(this.getValue()) == false) {
- this.setValue(5);
- }
- this.getDialog().params.updateVal(this.id, this.getValue());
- displaySelected(this.getDialog());
- },
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'text',
- id : 'animspeedid',
- label : lang.transitionTime,
- style : 'width:100px;',
- maxLength : 4,
- 'default' : '500',
- onChange : function( api ) {
- var intRegex = /^\d+$/;
- if(intRegex.test(this.getValue()) == false) {
- this.setValue(500);
- }
- this.getDialog().params.updateVal(this.id, this.getValue());
- displaySelected(this.getDialog());
- },
- commit : commitValue,
- setup : loadValue
- },
- {
- type : 'select',
- id : 'transitiontypeid',
- label : lang.transition,
- // add-gallery effects 'slide-vert', 'resize', 'fade', 'none' or false
- // effect: 'slide-hori',
- items : [ [ lang.tr1, 'none' ], [ lang.tr2, 'resize' ], [ lang.tr3, 'slide-vert' ], [ lang.tr4, 'slide-hori' ], [lang.tr5, 'fade'] ],
- 'default' : 'resize',
- style : 'width:100px;',
- commit : commitValue,
- setup : loadValue,
- onChange : commitValue
- }
- ]
- }
- ]
- }
- ]
- }
- ],
- onLoad: function() {
- },
- // Invoked when the dialog is loaded.
- onShow: function() {
- this.dialog = this;
- this.slideshowDOM = null;
- this.openCloseStep = true;
- this.fakeImage = null;
- var slideshowDOM = null;
- this.imagesList = [];
- this.params = [];
- // To get dimensions of poster image
- this.previewImage = editor.document.createElement( 'img' );
- this.okRefresh = true;
- var fakeImage = this.getSelectedElement();
- if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'slideShow' )
- {
- this.fakeImage = fakeImage;
- slideshowDOM = editor.restoreRealElement( fakeImage );
- }
- // Create a new <slideshow> slideshowDOM if it does not exist.
- if ( !slideshowDOM) {
- this.params.push(['slideshowid', numbering( 'slideShow' )]);
- // Insert placeHolder image
- initImgListFromFresh(this);
- // Invoke the commit methods of all dialog elements, so the dialog.params array get Updated.
- this.commitContent(this);
- // console.log( "Params New -> " + this.params );
- // console.log( "Images New -> " + this.imagesList );
- } else {
- this.slideshowDOM = slideshowDOM;
- // Get the reference of the slideSjow Images Container
- var slideShowContainer = getImagesContainerBlock(this, slideshowDOM);
- if (slideShowContainer == null) {
- alert("BIG Problem slideShowContainer !!");
- return false;
- }
- var slideshowid = slideshowDOM.getAttribute('id');
- if (slideshowid == null) {
- alert("BIG Problem slideshowid !!");
- return false;
- }
- this.params.push(['slideshowid', slideshowid]);
- // a DOM has been found updatet images List and Dialog box from this DOM
- initImgListFromDOM(this, slideShowContainer);
- // Init params Array from DOM
- // Copy all attributes to an array.
- var domDatas = slideshowDOM.$.dataset;
- var param;
- for ( param in domDatas ) {
- this.params.push( [ param, domDatas[ param ] ] );
- }
- // Invoke the setup methods of all dialog elements, to set dialog elements values with DOM input data.
- this.setupContent(this, true);
- //updateFramePreview(this);
- this.newSlideShowMode = false;
- // console.log( "Params Old -> " + this.params );
- // console.log( "Images Old -> " + this.imagesList );
- }
- this.openCloseStep = false;
- previewSlideShow(this);
- },
- // This method is invoked once a user clicks the OK button, confirming the dialog.
- // I just will return false, as the real OK Button has been redefined
- // -This was the only way I found to avoid dialog popup to close when hitting the keyboard "ENTER" Key !!
- onOk: function() {
- // var okr = this.okRefresh;
- // if (this.okRefresh == true) {
- // console.log('OKOKOK 0 :'+this.okRefresh);
- // this.okRefresh = false;
- // this.commitContent(this);
- // myVar = setTimeout(
- // function(obj){
- // obj.okRefresh = true;
- // },500, this);
- // }
- return false;
- },
- onHide: function() {
- cleanAll(this);
- }
- };
- });
|