123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629 |
- /**
- * 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) {
- //if (!(editor.config.slideshowDoNotLoadFancyBoxCss && (editor.config.slideshowDoNotLoadFancyBoxCss == true))) {
- strVar += "<link rel=\"stylesheet\" type=\"text\/css\" href=\""+CSS_FANCYBOX+"\" \/>";
- //}
- //if (!(editor.config.slideshowDoNotLoadFancyBoxScript && (editor.config.slideshowDoNotLoadFancyBoxScript == true))) {
- 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 += 'console.log("isrc:", isrc);';
- //str += "isrc = isrc.substr(0, isrc.lastIndexOf('.'));";
- //str += 'console.log("isrc:", isrc);';
- 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 !!
- if (!(editor.config.slideshowDoNotLoadFancyBoxCss && (editor.config.slideshowDoNotLoadFancyBoxCss == true))) {
- 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 !!
- if (!(editor.config.slideshowDoNotLoadFancyBoxScript && (editor.config.slideshowDoNotLoadFancyBoxScript == true))) {
- 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 = 'contain';
- extraStyles.backgroundRepeat = 'no-repeat';
- extraStyles.backgroundPosition = 'center';
- extraStyles.display = 'block';
- extraStyles.width = '64px';
- extraStyles.height = '64px';
- extraStyles.border = '1px solid black';
- // 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);
- }
- };
- });
|